aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/trailers_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/trailers_h.erl')
-rw-r--r--test/handlers/trailers_h.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/handlers/trailers_h.erl b/test/handlers/trailers_h.erl
new file mode 100644
index 0000000..a94d974
--- /dev/null
+++ b/test/handlers/trailers_h.erl
@@ -0,0 +1,18 @@
+%% Feel free to use, reuse and abuse the code in this file.
+
+-module(trailers_h).
+
+-export([init/2]).
+
+init(Req0, State) ->
+ Req = cowboy_req:stream_reply(200, #{
+ <<"content-type">> => <<"text/plain">>,
+ <<"trailer">> => <<"expires">>
+ }, Req0),
+ cowboy_req:stream_body(<<"Hello ">>, nofin, Req),
+ cowboy_req:stream_body(<<"world!">>, nofin, Req),
+ cowboy_req:stream_trailers(#{
+ <<"expires">> => <<"Sun, 10 Dec 2017 19:13:47 GMT">>
+ }, Req),
+ {ok, Req, State}.
+