diff options
author | Loïc Hoguin <[email protected]> | 2019-10-03 16:20:29 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-10-03 16:20:29 +0200 |
commit | 28aee1f2720da122f83758b141c503f7bff18ffb (patch) | |
tree | 76dfc7c03cd58726b6e645fff560093bbb0d9e1e /test | |
parent | 1ba48c58b1462fb9d9d8c4d9a43878679aea8eb7 (diff) | |
download | cowboy-28aee1f2720da122f83758b141c503f7bff18ffb.tar.gz cowboy-28aee1f2720da122f83758b141c503f7bff18ffb.tar.bz2 cowboy-28aee1f2720da122f83758b141c503f7bff18ffb.zip |
Document media type wildcard in content_types_accepted
Diffstat (limited to 'test')
-rw-r--r-- | test/handlers/content_types_accepted_h.erl | 2 | ||||
-rw-r--r-- | test/rest_handler_SUITE.erl | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/handlers/content_types_accepted_h.erl b/test/handlers/content_types_accepted_h.erl index d34135e..df72f06 100644 --- a/test/handlers/content_types_accepted_h.erl +++ b/test/handlers/content_types_accepted_h.erl @@ -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}. diff --git a/test/rest_handler_SUITE.erl b/test/rest_handler_SUITE.erl index cb734d9..43695c3 100644 --- a/test/rest_handler_SUITE.erl +++ b/test/rest_handler_SUITE.erl @@ -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 " |