aboutsummaryrefslogtreecommitdiffstats
path: root/src/cow_http.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/cow_http.erl')
-rw-r--r--src/cow_http.erl67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/cow_http.erl b/src/cow_http.erl
index 8504a21..7bb0562 100644
--- a/src/cow_http.erl
+++ b/src/cow_http.erl
@@ -18,7 +18,6 @@
-export([parse_status_line/1]).
-export([parse_headers/1]).
--export([parse_fullhost/1]).
-export([parse_fullpath/1]).
-export([parse_version/1]).
@@ -200,72 +199,6 @@ horse_parse_headers() ->
).
-endif.
-%% @doc Extract host and port from a binary.
-%%
-%% Because the hostname is case insensitive it is converted
-%% to lowercase.
-
--spec parse_fullhost(binary()) -> {binary(), undefined | non_neg_integer()}.
-parse_fullhost(<< $[, Rest/bits >>) ->
- parse_fullhost_ipv6(Rest, << $[ >>);
-parse_fullhost(Fullhost) ->
- parse_fullhost(Fullhost, <<>>).
-
-parse_fullhost_ipv6(<< $] >>, Acc) ->
- {<< Acc/binary, $] >>, undefined};
-parse_fullhost_ipv6(<< $], $:, Rest/bits >>, Acc) ->
- {<< Acc/binary, $] >>, binary_to_integer(Rest)};
-parse_fullhost_ipv6(<< C, Rest/bits >>, Acc) ->
- case C of
- ?INLINE_LOWERCASE(parse_fullhost_ipv6, Rest, Acc)
- end.
-
-parse_fullhost(<<>>, Acc) ->
- {Acc, undefined};
-parse_fullhost(<< $:, Rest/bits >>, Acc) ->
- {Acc, binary_to_integer(Rest)};
-parse_fullhost(<< C, Rest/bits >>, Acc) ->
- case C of
- ?INLINE_LOWERCASE(parse_fullhost, Rest, Acc)
- end.
-
--ifdef(TEST).
-parse_fullhost_test() ->
- {<<"example.org">>, 8080} = parse_fullhost(<<"example.org:8080">>),
- {<<"example.org">>, undefined} = parse_fullhost(<<"example.org">>),
- {<<"192.0.2.1">>, 8080} = parse_fullhost(<<"192.0.2.1:8080">>),
- {<<"192.0.2.1">>, undefined} = parse_fullhost(<<"192.0.2.1">>),
- {<<"[2001:db8::1]">>, 8080} = parse_fullhost(<<"[2001:db8::1]:8080">>),
- {<<"[2001:db8::1]">>, undefined} = parse_fullhost(<<"[2001:db8::1]">>),
- {<<"[::ffff:192.0.2.1]">>, 8080}
- = parse_fullhost(<<"[::ffff:192.0.2.1]:8080">>),
- {<<"[::ffff:192.0.2.1]">>, undefined}
- = parse_fullhost(<<"[::ffff:192.0.2.1]">>),
- ok.
--endif.
-
--ifdef(PERF).
-horse_parse_fullhost_blue_example_org() ->
- horse:repeat(200000,
- parse_fullhost(<<"blue.example.org:8080">>)
- ).
-
-horse_parse_fullhost_ipv4() ->
- horse:repeat(200000,
- parse_fullhost(<<"192.0.2.1:8080">>)
- ).
-
-horse_parse_fullhost_ipv6() ->
- horse:repeat(200000,
- parse_fullhost(<<"[2001:db8::1]:8080">>)
- ).
-
-horse_parse_fullhost_ipv6_v4() ->
- horse:repeat(200000,
- parse_fullhost(<<"[::ffff:192.0.2.1]:8080">>)
- ).
--endif.
-
%% @doc Extract path and query string from a binary.
-spec parse_fullpath(binary()) -> {binary(), binary()}.