aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Bytheway <[email protected]>2012-12-30 22:31:07 -0700
committerCameron Bytheway <[email protected]>2012-12-30 22:31:07 -0700
commitf1b4acbb441f665f7387ad30dda5bb861ec0400a (patch)
treeaca6b519f7117c0208af96f8ede0d76e96842830
parent2690d1254caffa2d85965baf95ed005c39fc820a (diff)
downloadcowboy-f1b4acbb441f665f7387ad30dda5bb861ec0400a.tar.gz
cowboy-f1b4acbb441f665f7387ad30dda5bb861ec0400a.tar.bz2
cowboy-f1b4acbb441f665f7387ad30dda5bb861ec0400a.zip
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)
-rw-r--r--src/cowboy_rest.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index c6b53bd..06655a4 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -747,7 +747,7 @@ choose_content_type(Req,
next(Req2, State2, OnTrue);
{false, Req2, HandlerState} ->
State2 = State#state{handler_state=HandlerState},
- respond(Req2, State2, 500)
+ respond(Req2, State2, 422)
end;
choose_content_type(Req, State, OnTrue, ContentType, [_Any|Tail]) ->
choose_content_type(Req, State, OnTrue, ContentType, Tail).