diff options
Diffstat (limited to 'test/handlers/resp_h.erl')
-rw-r--r-- | test/handlers/resp_h.erl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl index bfcb95c..7a80e75 100644 --- a/test/handlers/resp_h.erl +++ b/test/handlers/resp_h.erl @@ -219,6 +219,23 @@ do(<<"stream_body">>, Req0, Opts) -> Req = cowboy_req:stream_reply(200, Req0), cowboy_req:stream_body(<<"Hello world!">>, nofin, Req), {ok, Req, Opts}; + <<"sendfile">> -> + AppFile = code:where_is_file("cowboy.app"), + AppSize = filelib:file_size(AppFile), + Req = cowboy_req:stream_reply(200, Req0), + cowboy_req:stream_body(<<"Hello ">>, nofin, Req), + cowboy_req:stream_body({sendfile, 0, AppSize, AppFile}, nofin, Req), + cowboy_req:stream_body(<<" interspersed ">>, nofin, Req), + cowboy_req:stream_body({sendfile, 0, AppSize, AppFile}, nofin, Req), + cowboy_req:stream_body(<<" world!">>, fin, Req), + {ok, Req, Opts}; + <<"sendfile_fin">> -> + AppFile = code:where_is_file("cowboy.app"), + AppSize = filelib:file_size(AppFile), + Req = cowboy_req:stream_reply(200, Req0), + cowboy_req:stream_body(<<"Hello! ">>, nofin, Req), + cowboy_req:stream_body({sendfile, 0, AppSize, AppFile}, fin, Req), + {ok, Req, Opts}; _ -> %% Call stream_body without initiating streaming. cowboy_req:stream_body(<<0:800000>>, fin, Req0), |