diff options
author | Dmitry Groshev <[email protected]> | 2012-03-22 18:48:15 +0400 |
---|---|---|
committer | Dmitry Groshev <[email protected]> | 2012-03-22 18:48:15 +0400 |
commit | 6e0b764e0abfdbdbf174032358d43fb50f05e504 (patch) | |
tree | c0c285422c9b3cfe1a453695c3d762456a1cb184 /src | |
parent | 7e745824324187ed7b4559bc7c4eb6e40e87567c (diff) | |
download | cowboy-6e0b764e0abfdbdbf174032358d43fb50f05e504.tar.gz cowboy-6e0b764e0abfdbdbf174032358d43fb50f05e504.tar.bz2 cowboy-6e0b764e0abfdbdbf174032358d43fb50f05e504.zip |
Fixing badmatch when browser closes connection earlier than file was fully sent
Diffstat (limited to 'src')
-rw-r--r-- | src/cowboy_http_static.erl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cowboy_http_static.erl b/src/cowboy_http_static.erl index 007cd16..fcac4f8 100644 --- a/src/cowboy_http_static.erl +++ b/src/cowboy_http_static.erl @@ -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. |