mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Return 422 instead of 500 when handling body
Using a 4xx error would be more appropriate for this since the server is parsing the content from the client and needs to let the client know the data is malformed (not the actual HTTP request but i.e. JSON semantics). The definition for 422 is described in [RFC 4918](https://tools.ietf.org/html/rfc4918#section-11.2)
This commit is contained in:
parent
2690d1254c
commit
f1b4acbb44
1 changed files with 1 additions and 1 deletions
|
@ -747,7 +747,7 @@ choose_content_type(Req,
|
||||||
next(Req2, State2, OnTrue);
|
next(Req2, State2, OnTrue);
|
||||||
{false, Req2, HandlerState} ->
|
{false, Req2, HandlerState} ->
|
||||||
State2 = State#state{handler_state=HandlerState},
|
State2 = State#state{handler_state=HandlerState},
|
||||||
respond(Req2, State2, 500)
|
respond(Req2, State2, 422)
|
||||||
end;
|
end;
|
||||||
choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
|
choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
|
||||||
choose_content_type(Req, State, OnTrue, ContentType, Tail).
|
choose_content_type(Req, State, OnTrue, ContentType, Tail).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue