diff options
author | Loïc Hoguin <[email protected]> | 2013-09-04 19:24:54 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-09-04 19:24:54 +0200 |
commit | 4a30198f9068cc989616c8088e4b890bc1de259d (patch) | |
tree | 74f9847d6282c365e70245df13f77f3b5209faab /src/cowboy_protocol.erl | |
parent | bd0de074c364ddd7d8f3dfdcdb6e4261433716d8 (diff) | |
download | cowboy-4a30198f9068cc989616c8088e4b890bc1de259d.tar.gz cowboy-4a30198f9068cc989616c8088e4b890bc1de259d.tar.bz2 cowboy-4a30198f9068cc989616c8088e4b890bc1de259d.zip |
Make cowlib a proper dependency
Start moving a few functions from Cowboy into cowlib.
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r-- | src/cowboy_protocol.erl | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index 68a03b1..3c37983 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -54,7 +54,6 @@ %% Internal. -export([init/4]). -export([parse_request/3]). --export([parse_host/3]). -export([resume/6]). -type opts() :: [{compress, boolean()} @@ -443,6 +442,9 @@ default_port(ssl) -> 443; default_port(_) -> 80. %% Another hurtful block of code. :) +%% +%% 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) -> @@ -593,24 +595,3 @@ error_terminate(Status, Req, State) -> terminate(#state{socket=Socket, transport=Transport}) -> Transport:close(Socket), ok. - -%% Tests. - --ifdef(TEST). - -parse_host(RawHost) -> - parse_host(RawHost, false, <<>>). - -parse_host_test() -> - {<<"example.org">>, 8080} = parse_host(<<"example.org:8080">>), - {<<"example.org">>, undefined} = parse_host(<<"example.org">>), - {<<"192.0.2.1">>, 8080} = parse_host(<<"192.0.2.1:8080">>), - {<<"192.0.2.1">>, undefined} = parse_host(<<"192.0.2.1">>), - {<<"[2001:db8::1]">>, 8080} = parse_host(<<"[2001:db8::1]:8080">>), - {<<"[2001:db8::1]">>, undefined} = parse_host(<<"[2001:db8::1]">>), - {<<"[::ffff:192.0.2.1]">>, 8080} = - parse_host(<<"[::ffff:192.0.2.1]:8080">>), - {<<"[::ffff:192.0.2.1]">>, undefined} = - parse_host(<<"[::ffff:192.0.2.1]">>). - --endif. |