diff --git a/src/cowboy_http_static.erl b/src/cowboy_http_static.erl index 007cd1605..8b9f55861 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.