diff options
author | Loïc Hoguin <[email protected]> | 2018-11-21 17:39:12 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-21 18:39:59 +0100 |
commit | 037b286aa85acaaf439011bd7d2ae38685ce2f2e (patch) | |
tree | 2879aa405283eb15385efa02b71e2689337cda2f /src | |
parent | 800a4890092ebd30551c49fdae606ed5182bfdb1 (diff) | |
download | cowboy-037b286aa85acaaf439011bd7d2ae38685ce2f2e.tar.gz cowboy-037b286aa85acaaf439011bd7d2ae38685ce2f2e.tar.bz2 cowboy-037b286aa85acaaf439011bd7d2ae38685ce2f2e.zip |
Move many old HTTP test cases to the rest_handler test suite
A bug was fixed in cowboy_rest where when content_types_provided
returned a media type with a wildcard as first in the list, and
a request comes in without an accept header, then the media_type
value in the Req object would contain '*' instead of [] for the
parameters.
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_rest.erl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl index 76eda79..010bf05 100644 --- a/src/cowboy_rest.erl +++ b/src/cowboy_rest.erl @@ -479,7 +479,12 @@ content_types_provided(Req, State) -> State3 = State2#state{content_types_p=CTP2}, try cowboy_req:parse_header(<<"accept">>, Req2) of undefined -> - {PMT, _Fun} = HeadCTP = hd(CTP2), + {PMT0, _Fun} = HeadCTP = hd(CTP2), + %% We replace the wildcard by an empty list of parameters. + PMT = case PMT0 of + {Type, SubType, '*'} -> {Type, SubType, []}; + _ -> PMT0 + end, languages_provided( Req2#{media_type => PMT}, State3#state{content_type_a=HeadCTP}); |