aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-03-19 17:42:03 +0100
committerLoïc Hoguin <[email protected]>2011-03-19 17:42:03 +0100
commit2c52a30b0a209cfb0814a42b814271b168ddb2e2 (patch)
tree5991a067ba529f2c7a5dbc70b6334dbecff7a18e /src/cowboy_http_protocol.erl
parentebe638165e5a5285ae595c9e0ae07b3dd919881b (diff)
downloadcowboy-2c52a30b0a209cfb0814a42b814271b168ddb2e2.tar.gz
cowboy-2c52a30b0a209cfb0814a42b814271b168ddb2e2.tar.bz2
cowboy-2c52a30b0a209cfb0814a42b814271b168ddb2e2.zip
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.
Diffstat (limited to 'src/cowboy_http_protocol.erl')
-rw-r--r--src/cowboy_http_protocol.erl4
1 files changed, 3 insertions, 1 deletions
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.