aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-05-20 13:41:05 +0200
committerLoïc Hoguin <[email protected]>2020-05-20 13:41:05 +0200
commit39b2816255503910dc23e2fdf703ee63bbc8953e (patch)
tree65f9b843db941fd7ba1f3926b77ab34cbc5675f8 /test/handlers
parent8337aca4d31ffa8120704057675aacbbaa280975 (diff)
downloadcowboy-39b2816255503910dc23e2fdf703ee63bbc8953e.tar.gz
cowboy-39b2816255503910dc23e2fdf703ee63bbc8953e.tar.bz2
cowboy-39b2816255503910dc23e2fdf703ee63bbc8953e.zip
204 and 304 responses must not include a body
When calling cowboy_req:reply/4 with a body a crash will occur resulting in a 500 response. When calling cowboy_req:stream_reply/2,3 and then attempting to send a body a crash will occur.
Diffstat (limited to 'test/handlers')
-rw-r--r--test/handlers/resp_h.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index d43152e..8031d0e 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -181,6 +181,12 @@ do(<<"reply4">>, Req0, Opts) ->
<<"error">> ->
ct_helper:ignore(erlang, iolist_size, 1),
cowboy_req:reply(200, #{}, ok, Req0);
+ <<"204body">> ->
+ ct_helper:ignore(cowboy_req, reply, 4),
+ cowboy_req:reply(204, #{}, <<"OK">>, Req0);
+ <<"304body">> ->
+ ct_helper:ignore(cowboy_req, reply, 4),
+ cowboy_req:reply(304, #{}, <<"OK">>, Req0);
Status ->
cowboy_req:reply(binary_to_integer(Status), #{}, <<"OK">>, Req0)
end,
@@ -199,8 +205,15 @@ do(<<"stream_reply2">>, Req0, Opts) ->
<<"204">> ->
Req = cowboy_req:stream_reply(204, Req0),
{ok, Req, Opts};
- <<"304">> ->
+ <<"204body">> ->
+ ct_helper:ignore(cowboy_req, stream_body, 3),
+ Req = cowboy_req:stream_reply(204, Req0),
+ stream_body(Req),
+ {ok, Req, Opts};
+ <<"304body">> ->
+ ct_helper:ignore(cowboy_req, stream_body, 3),
Req = cowboy_req:stream_reply(304, Req0),
+ stream_body(Req),
{ok, Req, Opts};
Status ->
Req = cowboy_req:stream_reply(binary_to_integer(Status), Req0),