From 5cb2b544b7dcce296bdb956b14521fb036c26ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 11 Aug 2016 16:45:52 +0200 Subject: Use cow_http_hd:parse_host directly Removes some duplicate code from cowboy_http. --- src/cowboy_http.erl | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src') 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, -- cgit v1.2.3