aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-06-30 17:49:36 +0200
committerLoïc Hoguin <[email protected]>2014-06-30 17:49:36 +0200
commit4eee5737004df8cf63071c410eb4f060cb2dbaa2 (patch)
tree102e9e2d9905359e8aa5306b90b90fb2446f422f
parent8cc353114eea7113878463a934baf068ee255cb5 (diff)
downloadcowboy-4eee5737004df8cf63071c410eb4f060cb2dbaa2.tar.gz
cowboy-4eee5737004df8cf63071c410eb4f060cb2dbaa2.tar.bz2
cowboy-4eee5737004df8cf63071c410eb4f060cb2dbaa2.zip
Return 422 instead of 400 when AcceptResource returns false
422 is undefined for HTTP and interpreted as 400.
-rw-r--r--guide/rest_put_post_patch.pngbin219653 -> 218656 bytes
-rw-r--r--guide/rest_put_post_patch.svg10
-rw-r--r--src/cowboy_rest.erl2
-rw-r--r--test/http_SUITE.erl2
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
--- a/guide/rest_put_post_patch.png
+++ b/guide/rest_put_post_patch.png
Binary files 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 @@
<text
xml:space="preserve"
style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
- x="604.3656"
+ x="604.32263"
y="1242.303"
id="text5371-43-2-9-7-3-8"
sodipodi:linespacing="125%"
@@ -1338,8 +1338,8 @@
inkscape:export-ydpi="89.926643"><tspan
sodipodi:role="line"
id="tspan5373-3-9-7-8-7-5"
- x="604.3656"
- y="1242.303">422 unprocessable entity</tspan></text>
+ x="604.32263"
+ y="1242.303">400 bad request</tspan></text>
<g
transform="matrix(-0.34202014,-0.93969262,0.93969262,-0.34202014,-311.11659,1246.6148)"
id="g5650-2-0-4-0"
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index f76468a..fd1588a 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -780,7 +780,7 @@ process_content_type(Req, State=#state{method=Method, exists=Exists}, Fun) ->
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">>}
],