mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Ignore all extra Host values sent in the request.
This commit is contained in:
parent
673c7e2cb5
commit
ebe638165e
1 changed files with 5 additions and 2 deletions
|
@ -88,8 +88,8 @@ wait_header(Req, State=#state{socket=Socket,
|
||||||
|
|
||||||
-spec header({http_header, I::integer(), Field::http_header(), R::term(),
|
-spec header({http_header, I::integer(), Field::http_header(), R::term(),
|
||||||
Value::string()} | http_eoh, Req::#http_req{}, State::#state{}) -> ok.
|
Value::string()} | http_eoh, Req::#http_req{}, State::#state{}) -> ok.
|
||||||
header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path},
|
header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path,
|
||||||
State=#state{dispatch=Dispatch}) ->
|
host=undefined}, State=#state{dispatch=Dispatch}) ->
|
||||||
Value2 = string:to_lower(Value),
|
Value2 = string:to_lower(Value),
|
||||||
Host = cowboy_dispatcher:split_host(Value2),
|
Host = cowboy_dispatcher:split_host(Value2),
|
||||||
%% @todo We probably want to filter the Host and Path here to allow
|
%% @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, notfound} ->
|
||||||
error_terminate(404, State)
|
error_terminate(404, State)
|
||||||
end;
|
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) ->
|
header({http_header, _I, 'Connection', _R, Connection}, Req, State) ->
|
||||||
ConnAtom = connection_to_atom(Connection),
|
ConnAtom = connection_to_atom(Connection),
|
||||||
wait_header(Req#http_req{connection=ConnAtom,
|
wait_header(Req#http_req{connection=ConnAtom,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue