mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Document media type wildcard in content_types_accepted
This commit is contained in:
parent
1ba48c58b1
commit
28aee1f272
4 changed files with 26 additions and 2 deletions
|
@ -21,6 +21,8 @@ content_types_accepted(Req=#{qs := <<"multipart">>}, State) ->
|
|||
], Req, State};
|
||||
content_types_accepted(Req=#{qs := <<"param">>}, State) ->
|
||||
{[{{<<"text">>, <<"plain">>, [{<<"charset">>, <<"utf-8">>}]}, put_text_plain}], Req, State};
|
||||
content_types_accepted(Req=#{qs := <<"wildcard">>}, State) ->
|
||||
{[{'*', put_text_plain}], Req, State};
|
||||
content_types_accepted(Req=#{qs := <<"wildcard-param">>}, State) ->
|
||||
{[{{<<"text">>, <<"plain">>, '*'}, put_text_plain}], Req, State}.
|
||||
|
||||
|
|
|
@ -359,6 +359,24 @@ content_types_accepted_param(Config) ->
|
|||
{response, fin, 204, _} = gun:await(ConnPid, Ref),
|
||||
ok.
|
||||
|
||||
content_types_accepted_wildcard(Config) ->
|
||||
doc("When a wildcard is returned from the content_types_accepted "
|
||||
"callback, any content-type must be accepted."),
|
||||
ConnPid = gun_open(Config),
|
||||
Ref1 = gun:put(ConnPid, "/content_types_accepted?wildcard", [
|
||||
{<<"accept-encoding">>, <<"gzip">>},
|
||||
{<<"content-type">>, <<"text/plain">>}
|
||||
]),
|
||||
gun:data(ConnPid, Ref1, fin, "Hello world!"),
|
||||
{response, fin, 204, _} = gun:await(ConnPid, Ref1),
|
||||
Ref2 = gun:put(ConnPid, "/content_types_accepted?wildcard", [
|
||||
{<<"accept-encoding">>, <<"gzip">>},
|
||||
{<<"content-type">>, <<"application/vnd.plain;charset=UTF-8">>}
|
||||
]),
|
||||
gun:data(ConnPid, Ref2, fin, "Hello world!"),
|
||||
{response, fin, 204, _} = gun:await(ConnPid, Ref2),
|
||||
ok.
|
||||
|
||||
content_types_accepted_wildcard_param_no_content_type_param(Config) ->
|
||||
doc("When a wildcard is returned for parameters from the "
|
||||
"content_types_accepted callback, a content-type header "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue