aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/resp_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-01-09 13:06:11 +0100
committerLoïc Hoguin <[email protected]>2024-01-09 13:06:11 +0100
commit906a7ffc3ceaee166f495b071a92ce703f5ce39d (patch)
tree8267573d90b6db772c17d10ac626202227b1e660 /test/handlers/resp_h.erl
parentf0101ffe41b7ec6554c173dc218d60b97ee02d64 (diff)
downloadcowboy-906a7ffc3ceaee166f495b071a92ce703f5ce39d.tar.gz
cowboy-906a7ffc3ceaee166f495b071a92ce703f5ce39d.tar.bz2
cowboy-906a7ffc3ceaee166f495b071a92ce703f5ce39d.zip
Better error message when trying to reply twice
Also crash if trying to push after a reply was sent.
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r--test/handlers/resp_h.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index 735c654..db3844b 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -130,6 +130,10 @@ do(<<"inform2">>, Req0, Opts) ->
<<"twice">> ->
cowboy_req:inform(102, Req0),
cowboy_req:inform(102, Req0);
+ <<"after_reply">> ->
+ ct_helper:ignore(cowboy_req, inform, 3),
+ Req1 = cowboy_req:reply(200, Req0),
+ cowboy_req:inform(102, Req1);
Status ->
cowboy_req:inform(binary_to_integer(Status), Req0)
end,
@@ -146,6 +150,10 @@ do(<<"inform3">>, Req0, Opts) ->
<<"twice">> ->
cowboy_req:inform(102, Headers, Req0),
cowboy_req:inform(102, Headers, Req0);
+ <<"after_reply">> ->
+ ct_helper:ignore(cowboy_req, inform, 3),
+ Req1 = cowboy_req:reply(200, Req0),
+ cowboy_req:inform(102, Headers, Req1);
Status ->
cowboy_req:inform(binary_to_integer(Status), Headers, Req0)
end,
@@ -215,6 +223,13 @@ do(<<"stream_reply2">>, Req0, Opts) ->
Req = cowboy_req:stream_reply(304, Req0),
stream_body(Req),
{ok, Req, Opts};
+ <<"twice">> ->
+ ct_helper:ignore(cowboy_req, stream_reply, 3),
+ Req1 = cowboy_req:stream_reply(200, Req0),
+ %% We will crash here so the body shouldn't be sent.
+ Req = cowboy_req:stream_reply(200, Req1),
+ stream_body(Req),
+ {ok, Req, Opts};
Status ->
Req = cowboy_req:stream_reply(binary_to_integer(Status), Req0),
stream_body(Req),
@@ -403,6 +418,11 @@ do(<<"push">>, Req, Opts) ->
<<"qs">> ->
cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req,
#{qs => <<"server=cowboy&version=2.0">>});
+ <<"after_reply">> ->
+ ct_helper:ignore(cowboy_req, push, 4),
+ Req1 = cowboy_req:reply(200, Req),
+ %% We will crash here so no need to worry about propagating Req1.
+ cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req1);
_ ->
cowboy_req:push("/static/style.css", #{<<"accept">> => <<"text/css">>}, Req),
%% The text/plain mime is not defined by default, so a 406 will be returned.