mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Make cowboy_req:read_part return multipart headers as map
This commit is contained in:
parent
6f7b59886e
commit
ec00e3d60e
5 changed files with 19 additions and 20 deletions
|
@ -399,14 +399,13 @@ do_multipart(Path, Config) ->
|
|||
{<<"content-type">>, <<"multipart/mixed; boundary=deadbeef">>}
|
||||
], ReqBody, Config),
|
||||
[
|
||||
{[{<<"content-type">>, <<"text/plain">>}], <<"Cowboy is an HTTP server.">>},
|
||||
{#{<<"content-type">> := <<"text/plain">>}, <<"Cowboy is an HTTP server.">>},
|
||||
{LargeHeaders, LargeBody}
|
||||
] = binary_to_term(RespBody),
|
||||
%% @todo Multipart header order is currently undefined.
|
||||
[
|
||||
{<<"content-type">>, <<"application/octet-stream">>},
|
||||
{<<"x-custom">>, <<"value">>}
|
||||
] = lists:sort(LargeHeaders),
|
||||
#{
|
||||
<<"content-type">> := <<"application/octet-stream">>,
|
||||
<<"x-custom">> := <<"value">>
|
||||
} = LargeHeaders,
|
||||
ok.
|
||||
|
||||
read_part_skip_body(Config) ->
|
||||
|
@ -421,14 +420,13 @@ read_part_skip_body(Config) ->
|
|||
{<<"content-type">>, <<"multipart/mixed; boundary=deadbeef">>}
|
||||
], ReqBody, Config),
|
||||
[
|
||||
[{<<"content-type">>, <<"text/plain">>}],
|
||||
#{<<"content-type">> := <<"text/plain">>},
|
||||
LargeHeaders
|
||||
] = binary_to_term(RespBody),
|
||||
%% @todo Multipart header order is currently undefined.
|
||||
[
|
||||
{<<"content-type">>, <<"application/octet-stream">>},
|
||||
{<<"x-custom">>, <<"value">>}
|
||||
] = lists:sort(LargeHeaders),
|
||||
#{
|
||||
<<"content-type">> := <<"application/octet-stream">>,
|
||||
<<"x-custom">> := <<"value">>
|
||||
} = LargeHeaders,
|
||||
ok.
|
||||
|
||||
%% @todo When reading a multipart body, length and period
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue