mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +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:
parent
0995fc99e0
commit
4fd6e2f7cd
4 changed files with 34 additions and 12 deletions
|
@ -98,7 +98,7 @@
|
|||
%% Cowboy expects the real length as it is used as metadata.
|
||||
%% @todo We should probably explicitly reject it.
|
||||
-type resp_body() :: iodata()
|
||||
| {sendfile, non_neg_integer(), pos_integer(), file:name_all()}.
|
||||
| {sendfile, non_neg_integer(), non_neg_integer(), file:name_all()}.
|
||||
-export_type([resp_body/0]).
|
||||
|
||||
-type push_opts() :: #{
|
||||
|
@ -635,6 +635,11 @@ reply(Status, Headers, Req) ->
|
|||
-> Req when Req::req().
|
||||
reply(_, _, _, #{has_sent_resp := _}) ->
|
||||
error(function_clause);
|
||||
reply(Status, Headers, Sendfile = {sendfile, _, 0, _}, Req)
|
||||
when is_integer(Status); is_binary(Status) ->
|
||||
do_reply(Status, Headers#{
|
||||
<<"content-length">> => <<"0">>
|
||||
}, <<>>, Req);
|
||||
reply(Status, Headers, SendFile = {sendfile, _, Len, _}, Req)
|
||||
when is_integer(Status); is_binary(Status) ->
|
||||
do_reply(Status, Headers#{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue