mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
add base bitstring concat
This commit is contained in:
parent
c6491b82a8
commit
9af49cd4cd
2 changed files with 15 additions and 4 deletions
1
.tool-versions
Normal file
1
.tool-versions
Normal file
|
@ -0,0 +1 @@
|
||||||
|
erlang 26.2.2
|
|
@ -729,11 +729,21 @@ set_resp_header(Name,Value, Req) ->
|
||||||
% @todo process headers list - reduce to a map and concat the values of repeated headers, except for set-cookie that will be treated differently
|
% @todo process headers list - reduce to a map and concat the values of repeated headers, except for set-cookie that will be treated differently
|
||||||
% @todo define the correct spec
|
% @todo define the correct spec
|
||||||
-spec set_resp_headers_list(list(term()), req())
|
-spec set_resp_headers_list(list(term()), req())
|
||||||
set_resp_headers_list([], Req) ->
|
set_resp_headers_list(HeaderTupleList, Req) ->
|
||||||
|
set_resp_headers_list(HeaderTupleList, #{}, Req).
|
||||||
|
|
||||||
|
set_resp_headers_list([], Map, Req) ->
|
||||||
|
% @todo merge Map with Req headers
|
||||||
Req;
|
Req;
|
||||||
set_resp_headers_list([{Name, Value} | Headers], Req) ->
|
set_resp_headers_list([{Name, Value} | Headers], Map, Req) ->
|
||||||
Req1 = set_resp_header(Name, Value, Req),
|
NewHeaderValue = case maps:get(Name, Map, undefined) of
|
||||||
set_resp_headers_list(Headers, Req1).
|
undefined -> Value,
|
||||||
|
ExistingValue -> <<ExistingValue/binary, ", ", Value/binary>>
|
||||||
|
end,
|
||||||
|
|
||||||
|
Map1 = maps:put(Name, NewHeaderValue, Map),
|
||||||
|
|
||||||
|
set_resp_headers_list(Headers, Map1, Req1).
|
||||||
|
|
||||||
-spec set_resp_headers(cowboy:http_headers(), Req)
|
-spec set_resp_headers(cowboy:http_headers(), Req)
|
||||||
-> Req when Req::req().
|
-> Req when Req::req().
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue