0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

Return 422 instead of 400 when AcceptResource returns false

422 is undefined for HTTP and interpreted as 400.
This commit is contained in:
Loïc Hoguin 2014-06-30 17:49:36 +02:00
parent 8cc353114e
commit 4eee573700
4 changed files with 7 additions and 7 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Before After
Before After

View file

@ -65,8 +65,8 @@
inkscape:pageopacity="1" inkscape:pageopacity="1"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:zoom="2" inkscape:zoom="2"
inkscape:cx="-3.9389218" inkscape:cx="299.56028"
inkscape:cy="344.00863" inkscape:cy="-395.99137"
inkscape:document-units="px" inkscape:document-units="px"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
showgrid="false" showgrid="false"
@ -1329,7 +1329,7 @@
<text <text
xml:space="preserve" 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" 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" y="1242.303"
id="text5371-43-2-9-7-3-8" id="text5371-43-2-9-7-3-8"
sodipodi:linespacing="125%" sodipodi:linespacing="125%"
@ -1338,8 +1338,8 @@
inkscape:export-ydpi="89.926643"><tspan inkscape:export-ydpi="89.926643"><tspan
sodipodi:role="line" sodipodi:role="line"
id="tspan5373-3-9-7-8-7-5" id="tspan5373-3-9-7-8-7-5"
x="604.3656" x="604.32263"
y="1242.303">422 unprocessable entity</tspan></text> y="1242.303">400 bad request</tspan></text>
<g <g
transform="matrix(-0.34202014,-0.93969262,0.93969262,-0.34202014,-311.11659,1246.6148)" transform="matrix(-0.34202014,-0.93969262,0.93969262,-0.34202014,-311.11659,1246.6148)"
id="g5650-2-0-4-0" id="g5650-2-0-4-0"

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Before After
Before After

View file

@ -780,7 +780,7 @@ process_content_type(Req, State=#state{method=Method, exists=Exists}, Fun) ->
next(Req2, State2, fun maybe_created/2); next(Req2, State2, fun maybe_created/2);
{false, Req2, HandlerState2} -> {false, Req2, HandlerState2} ->
State2 = State#state{handler_state=HandlerState2}, State2 = State#state{handler_state=HandlerState2},
respond(Req2, State2, 422); respond(Req2, State2, 400);
{{true, ResURL}, Req2, HandlerState2} when Method =:= <<"POST">> -> {{true, ResURL}, Req2, HandlerState2} when Method =:= <<"POST">> ->
State2 = State#state{handler_state=HandlerState2}, State2 = State#state{handler_state=HandlerState2},
Req3 = cowboy_req:set_resp_header( Req3 = cowboy_req:set_resp_header(

View file

@ -749,7 +749,7 @@ rest_options_default(Config) ->
rest_patch(Config) -> rest_patch(Config) ->
Tests = [ Tests = [
{204, [{<<"content-type">>, <<"text/plain">>}], <<"whatever">>}, {204, [{<<"content-type">>, <<"text/plain">>}], <<"whatever">>},
{422, [{<<"content-type">>, <<"text/plain">>}], <<"false">>}, {400, [{<<"content-type">>, <<"text/plain">>}], <<"false">>},
{400, [{<<"content-type">>, <<"text/plain">>}], <<"halt">>}, {400, [{<<"content-type">>, <<"text/plain">>}], <<"halt">>},
{415, [{<<"content-type">>, <<"application/json">>}], <<"bad_content_type">>} {415, [{<<"content-type">>, <<"application/json">>}], <<"bad_content_type">>}
], ],