aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Groshev <[email protected]>2012-03-22 18:48:15 +0400
committerDmitry Groshev <[email protected]>2012-03-22 18:48:15 +0400
commit6e0b764e0abfdbdbf174032358d43fb50f05e504 (patch)
treec0c285422c9b3cfe1a453695c3d762456a1cb184 /src
parent7e745824324187ed7b4559bc7c4eb6e40e87567c (diff)
downloadcowboy-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.erl6
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.