From 2c52a30b0a209cfb0814a42b814271b168ddb2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 19 Mar 2011 17:42:03 +0100 Subject: Rewrite the dispatcher to take a list of host each having a list of paths. * Makes more sense to parse the host only once instead of for each path. * Allows proper handling of: If the host is not a valid host on the server, the response MUST be a 400 (Bad Request) error. --- src/cowboy_http_protocol.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/cowboy_http_protocol.erl') diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index 0ea2cd9..82cf733 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -99,7 +99,9 @@ header({http_header, _I, 'Host', _R, Value}, Req=#http_req{path=Path, wait_header(Req#http_req{host=Host, bindings=Binds, headers=[{'Host', Value2}|Req#http_req.headers]}, State#state{handler={Handler, Opts}}); - {error, notfound} -> + {error, notfound, host} -> + error_terminate(400, State); + {error, notfound, path} -> error_terminate(404, State) end; %% Ignore Host headers if we already have it. -- cgit v1.2.3