aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-11-30 16:44:57 +0100
committerLoïc Hoguin <[email protected]>2012-11-30 16:44:57 +0100
commit5c315ab1425965dfb2c10b274185a3fdf2645d1d (patch)
tree474870b3adb2010a60a6ef2913caec8b3c9c5853 /src
parent5f6b6b6f6d2fbae74d09a75d3b27446a99bc2d5e (diff)
downloadcowboy-5c315ab1425965dfb2c10b274185a3fdf2645d1d.tar.gz
cowboy-5c315ab1425965dfb2c10b274185a3fdf2645d1d.tar.bz2
cowboy-5c315ab1425965dfb2c10b274185a3fdf2645d1d.zip
Return a 400 error if the Accept header was incorrect
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_rest.erl9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index 446558c..721acb9 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -211,14 +211,15 @@ content_types_provided(Req, State) ->
CTP2 = [normalize_content_types(P) || P <- CTP],
State2 = State#state{
handler_state=HandlerState, content_types_p=CTP2},
- {ok, Accept, Req3} = cowboy_req:parse_header(<<"accept">>, Req2),
- case Accept of
- undefined ->
+ case cowboy_req:parse_header(<<"accept">>, Req2) of
+ {error, badarg} ->
+ respond(Req2, State2, 400);
+ {ok, undefined, Req3} ->
{PMT, _Fun} = HeadCTP = hd(CTP2),
languages_provided(
cowboy_req:set_meta(media_type, PMT, Req3),
State2#state{content_type_a=HeadCTP});
- Accept ->
+ {ok, Accept, Req3} ->
Accept2 = prioritize_accept(Accept),
choose_media_type(Req3, State2, Accept2)
end