aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/handlers/resp_h.erl20
-rw-r--r--test/req_SUITE.erl10
2 files changed, 26 insertions, 4 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index 94c7f60..add90ad 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -188,10 +188,22 @@ do(<<"stream_reply3">>, Req0, Opts) ->
end,
stream_body(Req),
{ok, Req, Opts};
-do(<<"stream_body">>, Req, Opts) ->
- %% Call stream_body without initiating streaming.
- cowboy_req:stream_body(<<0:800000>>, fin, Req),
- {ok, Req, Opts};
+do(<<"stream_body">>, Req0, Opts) ->
+ case cowboy_req:binding(arg, Req0) of
+ <<"fin0">> ->
+ Req = cowboy_req:stream_reply(200, Req0),
+ cowboy_req:stream_body(<<"Hello world!">>, nofin, Req),
+ cowboy_req:stream_body(<<>>, fin, Req),
+ {ok, Req, Opts};
+ <<"nofin">> ->
+ Req = cowboy_req:stream_reply(200, Req0),
+ cowboy_req:stream_body(<<"Hello world!">>, nofin, Req),
+ {ok, Req, Opts};
+ _ ->
+ %% Call stream_body without initiating streaming.
+ cowboy_req:stream_body(<<0:800000>>, fin, Req0),
+ {ok, Req0, Opts}
+ end;
do(<<"push">>, Req, Opts) ->
case cowboy_req:binding(arg, Req) of
<<"method">> ->
diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl
index 107cdd8..862ee53 100644
--- a/test/req_SUITE.erl
+++ b/test/req_SUITE.erl
@@ -827,6 +827,16 @@ stream_reply3(Config) ->
{500, _, _} = do_get("/resp/stream_reply3/error", Config),
ok.
+stream_body_fin0(Config) ->
+ doc("Streamed body with last chunk of size 0."),
+ {200, _, <<"Hello world!">>} = do_get("/resp/stream_body/fin0", Config),
+ ok.
+
+stream_body_nofin(Config) ->
+ doc("Unfinished streamed body."),
+ {200, _, <<"Hello world!">>} = do_get("/resp/stream_body/nofin", Config),
+ ok.
+
%% @todo Crash when calling stream_body after the fin flag has been set.
%% @todo Crash when calling stream_body after calling reply.
%% @todo Crash when calling stream_body before calling stream_reply.