0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Fix set-cookie response value check

* Allow a single set-cookie binary as a response header value
  (assuming the value is a list occurs when it isn't a binary)
This commit is contained in:
Michael Truog 2021-05-28 23:29:25 -07:00
parent 2a08250499
commit 983a07c1be
No known key found for this signature in database
GPG key ID: ADD76627CDC2E50F

View file

@ -1216,7 +1216,7 @@ commands(State, StreamID, [{push, _, _, _, _, _, _, _}|Tail]) ->
commands(State, StreamID, Tail). commands(State, StreamID, Tail).
%% The set-cookie header is special; we can only send one cookie per header. %% The set-cookie header is special; we can only send one cookie per header.
headers_to_list(Headers0=#{<<"set-cookie">> := SetCookies}) -> headers_to_list(Headers0=#{<<"set-cookie">> := SetCookies}) when not is_binary(SetCookies) ->
Headers1 = maps:to_list(maps:remove(<<"set-cookie">>, Headers0)), Headers1 = maps:to_list(maps:remove(<<"set-cookie">>, Headers0)),
Headers1 ++ [{<<"set-cookie">>, Value} || Value <- SetCookies]; Headers1 ++ [{<<"set-cookie">>, Value} || Value <- SetCookies];
headers_to_list(Headers) -> headers_to_list(Headers) ->