aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2016-08-11 16:45:52 +0200
committerLoïc Hoguin <[email protected]>2016-08-11 16:45:52 +0200
commit5cb2b544b7dcce296bdb956b14521fb036c26ed8 (patch)
tree78f1fbdd05fff0d336a19f0d5414e3cb205ca370
parentb75b0a6d4dbdffd1346c9982a81377a4d95ce8db (diff)
downloadcowboy-5cb2b544b7dcce296bdb956b14521fb036c26ed8.tar.gz
cowboy-5cb2b544b7dcce296bdb956b14521fb036c26ed8.tar.bz2
cowboy-5cb2b544b7dcce296bdb956b14521fb036c26ed8.zip
Use cow_http_hd:parse_host directly
Removes some duplicate code from cowboy_http.
-rw-r--r--src/cowboy_http.erl16
1 files changed, 1 insertions, 15 deletions
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 0f5d0ae..ae42e6d 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -555,7 +555,7 @@ request(Buffer, State=#state{transport=Transport, in_streamid=StreamID,
undefined ->
request(Buffer, State, Headers, <<>>, default_port(Transport:secure()));
RawHost ->
- try parse_host(RawHost, false, <<>>) of
+ try cow_http_hd:parse_host(RawHost) of
{Host, undefined} ->
request(Buffer, State, Headers, Host, default_port(Transport:secure()));
{Host, Port} ->
@@ -570,20 +570,6 @@ request(Buffer, State=#state{transport=Transport, in_streamid=StreamID,
default_port(true) -> 443;
default_port(_) -> 80.
-%% @todo Yeah probably just call the cowlib function.
-%% Same code as cow_http:parse_fullhost/1, but inline because we
-%% really want this to go fast.
-parse_host(<< $[, Rest/bits >>, false, <<>>) ->
- parse_host(Rest, true, << $[ >>);
-parse_host(<<>>, false, Acc) ->
- {Acc, undefined};
-parse_host(<< $:, Rest/bits >>, false, Acc) ->
- {Acc, binary_to_integer(Rest)};
-parse_host(<< $], Rest/bits >>, true, Acc) ->
- parse_host(Rest, false, << Acc/binary, $] >>);
-parse_host(<< C, Rest/bits >>, E, Acc) ->
- ?LOWER(parse_host, Rest, E, Acc).
-
%% End of request parsing.
request(Buffer, State0=#state{ref=Ref, transport=Transport, peer=Peer, in_streamid=StreamID,