0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00

rest: reject incorrect content-type header

This commit is contained in:
Vladimir Dronnikov 2013-04-12 09:51:47 +04:00
parent fa31c82595
commit 180143f9b2
2 changed files with 17 additions and 3 deletions

View file

@ -776,9 +776,12 @@ accept_resource(Req, State, OnTrue) ->
{CTA, Req2, HandlerState} ->
CTA2 = [normalize_content_types(P) || P <- CTA],
State2 = State#state{handler_state=HandlerState},
{ok, ContentType, Req3}
= cowboy_req:parse_header(<<"content-type">>, Req2),
choose_content_type(Req3, State2, OnTrue, ContentType, CTA2)
case cowboy_req:parse_header(<<"content-type">>, Req2) of
{ok, ContentType, Req3} ->
choose_content_type(Req3, State2, OnTrue, ContentType, CTA2);
{error, badarg} ->
respond(Req2, State2, 415)
end
end.
%% The special content type '*' will always match. It can be used as a