aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/stream_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/stream_h.erl')
-rw-r--r--test/handlers/stream_h.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/handlers/stream_h.erl b/test/handlers/stream_h.erl
new file mode 100644
index 0000000..fd6774e
--- /dev/null
+++ b/test/handlers/stream_h.erl
@@ -0,0 +1,14 @@
+%% Feel free to use, reuse and abuse the code in this file.
+
+-module(stream_h).
+
+-export([init/2]).
+
+init(Req0, State) ->
+ Req = cowboy_req:stream_reply(200, #{
+ <<"content-type">> => <<"text/plain">>
+ }, Req0),
+ cowboy_req:stream_body(<<"Hello ">>, nofin, Req),
+ cowboy_req:stream_body(<<"world!">>, nofin, Req),
+ %% The stream will be closed by Cowboy.
+ {ok, Req, State}.