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

@ -156,7 +156,7 @@ resp_body() :: iodata()
| {sendfile, Offset, Length, Filename}
Offset :: non_neg_integer()
Length :: pos_integer()
Length :: non_neg_integer()
Filename :: file:name_all()
----
@ -180,16 +180,9 @@ order they should be sent:
Hello world!
----
When using the sendfile tuple, the `Length` value is mandatory
and must be higher than 0. It is sent with the response in the
content-length header.
// @todo Make sure we have a test with an empty file...
// @todo cowboy_static should probably NOT return a sendfile tuple if size is 0.
//%% While sendfile allows a Len of 0 that means "everything past Offset",
//%% Cowboy expects the real length as it is used as metadata.
//%% @todo We should probably explicitly reject it.
Note that the length must be greater than zero for any data
to be sent. Cowboy will send an empty body when the length
is zero.
== See also