aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cowboy_req.erl21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index dddf92e..14eb88d 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -1183,7 +1183,7 @@ parse_connection(<<>>, Acc, Token) ->
lists:reverse([Token|Acc]);
parse_connection(<< C, Rest/bits >>, Acc, Token)
when C =:= $,; C =:= $\s; C =:= $\t ->
- parse_connection_after(Rest, [Token|Acc]);
+ parse_connection_before(Rest, [Token|Acc]);
parse_connection(<< C, Rest/bits >>, Acc, Token) ->
case C of
$A -> parse_connection(Rest, Acc, << Token/binary, $a >>);
@@ -1215,14 +1215,6 @@ parse_connection(<< C, Rest/bits >>, Acc, Token) ->
C -> parse_connection(Rest, Acc, << Token/binary, C >>)
end.
-parse_connection_after(<<>>, Acc) ->
- lists:reverse(Acc);
-parse_connection_after(<< $,, Rest/bits >>, Acc) ->
- parse_connection_before(Rest, Acc);
-parse_connection_after(<< C, Rest/bits >>, Acc)
- when C =:= $\s; C =:= $\t ->
- parse_connection_after(Rest, Acc).
-
%% @doc Walk through a tokens list and return whether
%% the connection is keepalive or closed.
%%
@@ -1333,6 +1325,17 @@ url_test() ->
pid=self()}),
ok.
+parse_connection_test_() ->
+ %% {Binary, Result}
+ Tests = [
+ {<<"close">>, [<<"close">>]},
+ {<<"ClOsE">>, [<<"close">>]},
+ {<<"Keep-Alive">>, [<<"keep-alive">>]},
+ {<<"keep-alive, Upgrade">>, [<<"keep-alive">>, <<"upgrade">>]}
+ ],
+ [{B, fun() -> R = parse_connection_before(B, []) end}
+ || {B, R} <- Tests].
+
connection_to_atom_test_() ->
%% {Tokens, Result}
Tests = [