diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-10-11 18:53:53 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-10-11 18:53:53 +0300 |
commit | e5e64c99f387f667e56399c90a43ed28c39ebed3 (patch) | |
tree | 855a7a914e393c80acca9ca5e0ee82a77b686f27 /src | |
parent | 2832130afc4f4b1475ce1192aeb0a389dc2c11d6 (diff) |
Don't crash when Host header is missing
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_http.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 43bbb3f04..30cce1952 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -266,10 +266,11 @@ process_header(State, Data) -> add_header(Name, Value, State)}; {ok, http_eoh} when State#state.request_host == undefined -> - ?WARNING_MSG("An HTTP request without 'Host' HTTP " - "header was received.", - []), - throw(http_request_no_host_header); + ?DEBUG("An HTTP request without 'Host' HTTP " + "header was received.", []), + {State1, Out} = process_request(State), + send_text(State1, Out), + process_header(State, {ok, {http_error, <<>>}}); {ok, http_eoh} -> ?DEBUG("(~w) http query: ~w ~p~n", [State#state.socket, State#state.request_method, @@ -418,6 +419,10 @@ extract_path_query(#state{request_method = Method, extract_path_query(State) -> {State, false}. +process_request(#state{request_host = undefined, + custom_headers = CustomHeaders} = State) -> + {State, make_text_output(State, 400, CustomHeaders, + <<"Missing Host header">>)}; process_request(#state{request_method = Method, request_auth = Auth, request_lang = Lang, |