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

Fixing badmatch when browser closes connection earlier than file was fully sent

This commit is contained in:
Dmitry Groshev 2012-03-22 18:48:15 +04:00
parent 7e74582432
commit 6e0b764e0a

View file

@ -316,8 +316,10 @@ sfallback(Transport, Socket, File, Sent) ->
ok = file:close(File),
{sent, Sent};
{ok, Bin} ->
ok = Transport:send(Socket, Bin),
sfallback(Transport, Socket, File, Sent + byte_size(Bin))
case Transport:send(Socket, Bin) of
ok -> sfallback(Transport, Socket, File, Sent + byte_size(Bin));
{error, closed} -> {sent, Sent}
end
end.