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

@ -43,12 +43,25 @@ do(<<"set_resp_headers">>, Req0, Opts) ->
<<"content-encoding">> => <<"compress">>
}, Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_headers_list">>, Req0, Opts) ->
Req = cowboy_req:set_resp_headers([
{<<"content-type">>, <<"text/plain">>},
{<<"content-encoding">>, <<"compress">>}
], Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_headers_cookie">>, Req0, Opts) ->
ct_helper:ignore(cowboy_req, set_resp_headers, 2),
Req = cowboy_req:set_resp_headers(#{
<<"set-cookie">> => <<"name=value">>
}, Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_headers_list_cookie">>, Req0, Opts) ->
ct_helper:ignore(cowboy_req, set_resp_headers_list, 3),
Req = cowboy_req:set_resp_headers([
{<<"set-cookie">>, <<"name=value">>},
{<<"set-cookie">>, <<"name2=value2">>}
], Req0),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
do(<<"set_resp_headers_http11">>, Req0, Opts) ->
Req = cowboy_req:set_resp_headers(#{
<<"connection">> => <<"custom-header, close">>,