aboutsummaryrefslogtreecommitdiffstats
path: root/test/handlers/compress_h.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/handlers/compress_h.erl')
-rw-r--r--test/handlers/compress_h.erl25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/handlers/compress_h.erl b/test/handlers/compress_h.erl
index 4b4dbe7..1509d82 100644
--- a/test/handlers/compress_h.erl
+++ b/test/handlers/compress_h.erl
@@ -27,7 +27,30 @@ init(Req0, State=stream_reply) ->
<<"large">> ->
stream_reply(#{}, Req0);
<<"content-encoding">> ->
- stream_reply(#{<<"content-encoding">> => <<"compress">>}, Req0)
+ stream_reply(#{<<"content-encoding">> => <<"compress">>}, Req0);
+ <<"sendfile">> ->
+ Data = lists:duplicate(10000, $a),
+ AppFile = code:where_is_file("cowboy.app"),
+ Size = filelib:file_size(AppFile),
+ Req1 = cowboy_req:stream_reply(200, Req0),
+ %% We send a few files interspersed into other data.
+ cowboy_req:stream_body(Data, nofin, Req1),
+ cowboy_req:stream_body({sendfile, 0, Size, AppFile}, nofin, Req1),
+ cowboy_req:stream_body(Data, nofin, Req1),
+ cowboy_req:stream_body({sendfile, 0, Size, AppFile}, nofin, Req1),
+ cowboy_req:stream_body(Data, fin, Req1),
+ Req1;
+ <<"sendfile_fin">> ->
+ Data = lists:duplicate(10000, $a),
+ AppFile = code:where_is_file("cowboy.app"),
+ Size = filelib:file_size(AppFile),
+ Req1 = cowboy_req:stream_reply(200, Req0),
+ %% We send a few files interspersed into other data.
+ cowboy_req:stream_body(Data, nofin, Req1),
+ cowboy_req:stream_body({sendfile, 0, Size, AppFile}, nofin, Req1),
+ cowboy_req:stream_body(Data, nofin, Req1),
+ cowboy_req:stream_body({sendfile, 0, Size, AppFile}, fin, Req1),
+ Req1
end,
{ok, Req, State}.