aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-03-19 16:49:06 +0100
committerLoïc Hoguin <[email protected]>2011-03-19 16:49:06 +0100
commitebe638165e5a5285ae595c9e0ae07b3dd919881b (patch)
tree57e7583e9abbcd8d570049967bbf72c39568b35f
parent673c7e2cb5dbf08e8f146d3146cfa883410f7db1 (diff)
downloadcowboy-ebe638165e5a5285ae595c9e0ae07b3dd919881b.tar.gz
cowboy-ebe638165e5a5285ae595c9e0ae07b3dd919881b.tar.bz2
cowboy-ebe638165e5a5285ae595c9e0ae07b3dd919881b.zip
Ignore all extra Host values sent in the request.
-rw-r--r--src/cowboy_http_protocol.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl
index 0840b70..0ea2cd9 100644
--- a/src/cowboy_http_protocol.erl
+++ b/src/cowboy_http_protocol.erl
@@ -88,8 +88,8 @@ wait_header(Req, State=#state{socket=Socket,
-spec header({http_header, I::integer(), Field::http_header(), R::term(),
Value::string()} | http_eoh, Req::#http_req{}, State::#state{}) -> ok.
-header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path},
- State=#state{dispatch=Dispatch}) ->
+header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path,
+ host=undefined}, State=#state{dispatch=Dispatch}) ->
Value2 = string:to_lower(Value),
Host = cowboy_dispatcher:split_host(Value2),
%% @todo We probably want to filter the Host and Path here to allow
@@ -102,6 +102,9 @@ header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path},
{error, notfound} ->
error_terminate(404, State)
end;
+%% Ignore Host headers if we already have it.
+header({http_header, _I, 'Host', _R, _V}, Req, State) ->
+ wait_header(Req, State);
header({http_header, _I, 'Connection', _R, Connection}, Req, State) ->
ConnAtom = connection_to_atom(Connection),
wait_header(Req#http_req{connection=ConnAtom,