From 4eee5737004df8cf63071c410eb4f060cb2dbaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 30 Jun 2014 17:49:36 +0200 Subject: Return 422 instead of 400 when AcceptResource returns false 422 is undefined for HTTP and interpreted as 400. --- guide/rest_put_post_patch.png | Bin 219653 -> 218656 bytes guide/rest_put_post_patch.svg | 10 +++++----- src/cowboy_rest.erl | 2 +- test/http_SUITE.erl | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/guide/rest_put_post_patch.png b/guide/rest_put_post_patch.png index de2ce2f..4afca9e 100644 Binary files a/guide/rest_put_post_patch.png and b/guide/rest_put_post_patch.png differ diff --git a/guide/rest_put_post_patch.svg b/guide/rest_put_post_patch.svg index 9992534..263cc94 100644 --- a/guide/rest_put_post_patch.svg +++ b/guide/rest_put_post_patch.svg @@ -65,8 +65,8 @@ inkscape:pageopacity="1" inkscape:pageshadow="2" inkscape:zoom="2" - inkscape:cx="-3.9389218" - inkscape:cy="344.00863" + inkscape:cx="299.56028" + inkscape:cy="-395.99137" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -1329,7 +1329,7 @@ 422 unprocessable entity + x="604.32263" + y="1242.303">400 bad request next(Req2, State2, fun maybe_created/2); {false, Req2, HandlerState2} -> State2 = State#state{handler_state=HandlerState2}, - respond(Req2, State2, 422); + respond(Req2, State2, 400); {{true, ResURL}, Req2, HandlerState2} when Method =:= <<"POST">> -> State2 = State#state{handler_state=HandlerState2}, Req3 = cowboy_req:set_resp_header( diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 0e115e0..5888421 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -749,7 +749,7 @@ rest_options_default(Config) -> rest_patch(Config) -> Tests = [ {204, [{<<"content-type">>, <<"text/plain">>}], <<"whatever">>}, - {422, [{<<"content-type">>, <<"text/plain">>}], <<"false">>}, + {400, [{<<"content-type">>, <<"text/plain">>}], <<"false">>}, {400, [{<<"content-type">>, <<"text/plain">>}], <<"halt">>}, {415, [{<<"content-type">>, <<"application/json">>}], <<"bad_content_type">>} ], -- cgit v1.2.3