0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Change the response body streaming fun interface

Before we were required to get the socket and transport ourselves,
now they're passed to the function.
This commit is contained in:
Loïc Hoguin 2013-01-05 20:19:43 +01:00
parent d8be610d4c
commit 58e89e2189
3 changed files with 9 additions and 6 deletions

View file

@ -321,8 +321,10 @@ content_types_provided(Req, #state{filepath=Filepath,
-spec file_contents(cowboy_req:req(), #state{}) -> tuple().
file_contents(Req, #state{filepath=Filepath,
fileinfo={ok, #file_info{size=Filesize}}}=State) ->
{ok, Transport, Socket} = cowboy_req:transport(Req),
Writefile = fun() -> Transport:sendfile(Socket, Filepath) end,
Writefile = fun(Socket, Transport) ->
{ok, _} = Transport:sendfile(Socket, Filepath),
ok
end,
{{stream, Filesize, Writefile}, Req, State}.