mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Fix the parsing of the Connection header
This commit is contained in:
parent
3969b51a55
commit
7367f07ca0
1 changed files with 12 additions and 9 deletions
|
@ -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 = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue