aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_protocol.erl4
-rw-r--r--src/cowboy_req.erl2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index 0d15f32..7ab66a9 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -379,7 +379,9 @@ request(B, State=#state{transport=Transport}, M, P, Q, F, Version, Headers) ->
request(B, State, M, P, Q, F, Version, Headers,
<<>>, default_port(Transport:name()));
{_, RawHost} ->
- case parse_host(RawHost, <<>>) of
+ case catch parse_host(RawHost, <<>>) of
+ {'EXIT', _} ->
+ error_terminate(400, State);
{Host, undefined} ->
request(B, State, M, P, Q, F, Version, Headers,
Host, default_port(Transport:name()));
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index b29d694..8525247 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -537,7 +537,7 @@ meta(Name, Req, Default) ->
%% If the value already exists it will be overwritten.
-spec set_meta(atom(), any(), Req) -> Req when Req::req().
set_meta(Name, Value, Req=#http_req{meta=Meta}) ->
- Req#http_req{meta=[{Name, Value}|lists:keydelete(Name, 1, Meta)]}.
+ Req#http_req{meta=lists:keyreplace(Name, 1, Meta, {Name, Value})}.
%% Request Body API.