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

Add support for lists in cowboy_req:set_resp_headers

This is meant to be used with clients such as Gun to simplify
proxying and similar operations. The set-cookie header must
not be set this way so there is still some extra processing
to be done to fully translate a Gun response into a Cowboy
response.
This commit is contained in:
Loïc Hoguin 2025-02-11 12:00:03 +01:00
parent f316a65906
commit e8a1868033
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
4 changed files with 48 additions and 7 deletions

View file

@ -858,11 +858,15 @@ set_resp_header(Config) ->
set_resp_headers(Config) ->
doc("Response using set_resp_headers."),
{200, Headers, <<"OK">>} = do_get("/resp/set_resp_headers", Config),
true = lists:keymember(<<"content-type">>, 1, Headers),
true = lists:keymember(<<"content-encoding">>, 1, Headers),
{200, Headers1, <<"OK">>} = do_get("/resp/set_resp_headers", Config),
true = lists:keymember(<<"content-type">>, 1, Headers1),
true = lists:keymember(<<"content-encoding">>, 1, Headers1),
{200, Headers2, <<"OK">>} = do_get("/resp/set_resp_headers_list", Config),
true = lists:keymember(<<"content-type">>, 1, Headers2),
true = lists:keymember(<<"content-encoding">>, 1, Headers2),
%% The set-cookie header is special. set_resp_cookie must be used.
{500, _, _} = do_maybe_h3_error3(do_get("/resp/set_resp_headers_cookie", Config)),
{500, _, _} = do_maybe_h3_error3(do_get("/resp/set_resp_headers_list_cookie", Config)),
ok.
resp_header(Config) ->