aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/resp_h.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-10-29 19:52:27 +0000
committerLoïc Hoguin <[email protected]>2017-10-29 21:03:04 +0000
commitf3d6b05b863fe177a34a8a6ba48c5f263ef8cf82 (patch)
treefc3235ad43880f29186bce373a3c79057c83e060 /test/handlers/resp_h.erl
parentf4331f7c169309c9017b9628fe3757fc5312270b (diff)
downloadcowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.tar.gz
cowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.tar.bz2
cowboy-f3d6b05b863fe177a34a8a6ba48c5f263ef8cf82.zip
Add cowboy_req:inform/2,3
User code can now send as many 1xx responses as necessary.
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r--test/handlers/resp_h.erl31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index 9b94e3f..94c7f60 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -100,6 +100,37 @@ do(<<"delete_resp_header">>, Req0, Opts) ->
Req = cowboy_req:delete_resp_header(<<"content-type">>, Req1),
false = cowboy_req:has_resp_header(<<"content-type">>, Req),
{ok, cowboy_req:reply(200, #{}, "OK", Req), Opts};
+do(<<"inform2">>, Req0, Opts) ->
+ case cowboy_req:binding(arg, Req0) of
+ <<"binary">> ->
+ cowboy_req:inform(<<"102 On my way">>, Req0);
+ <<"error">> ->
+ ct_helper:ignore(cowboy_req, inform, 3),
+ cowboy_req:inform(ok, Req0);
+ <<"twice">> ->
+ cowboy_req:inform(102, Req0),
+ cowboy_req:inform(102, Req0);
+ Status ->
+ cowboy_req:inform(binary_to_integer(Status), Req0)
+ end,
+ Req = cowboy_req:reply(200, Req0),
+ {ok, Req, Opts};
+do(<<"inform3">>, Req0, Opts) ->
+ Headers = #{<<"ext-header">> => <<"ext-value">>},
+ case cowboy_req:binding(arg, Req0) of
+ <<"binary">> ->
+ cowboy_req:inform(<<"102 On my way">>, Headers, Req0);
+ <<"error">> ->
+ ct_helper:ignore(cowboy_req, inform, 3),
+ cowboy_req:inform(ok, Headers, Req0);
+ <<"twice">> ->
+ cowboy_req:inform(102, Headers, Req0),
+ cowboy_req:inform(102, Headers, Req0);
+ Status ->
+ cowboy_req:inform(binary_to_integer(Status), Headers, Req0)
+ end,
+ Req = cowboy_req:reply(200, Req0),
+ {ok, Req, Opts};
do(<<"reply2">>, Req0, Opts) ->
Req = case cowboy_req:binding(arg, Req0) of
<<"binary">> ->