From 037b286aa85acaaf439011bd7d2ae38685ce2f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 21 Nov 2018 17:39:12 +0100 Subject: 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. --- src/cowboy_rest.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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}); -- cgit v1.2.3