0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 04:30:25 +00:00

Accept sendfile tuple with 0 length in cowboy_req

This will result in no data being sent. It's simply easier to
do this than to have to handle 0 size cases in user code.
This commit is contained in:
Loïc Hoguin 2017-09-04 20:48:07 +02:00
parent 0995fc99e0
commit 4fd6e2f7cd
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
4 changed files with 34 additions and 12 deletions

View file

@ -58,6 +58,9 @@ do(<<"resp_headers_empty">>, Req, Opts) ->
do(<<"set_resp_body">>, Req0, Opts) ->
Arg = cowboy_req:binding(arg, Req0),
Req1 = case Arg of
<<"sendfile0">> ->
AppFile = code:where_is_file("cowboy.app"),
cowboy_req:set_resp_body({sendfile, 0, 0, AppFile}, Req0);
<<"sendfile">> ->
AppFile = code:where_is_file("cowboy.app"),
cowboy_req:set_resp_body({sendfile, 0, filelib:file_size(AppFile), AppFile}, Req0);