Catch connection reset when proxying files

This commit is contained in:
Omar Roth 2019-05-26 09:41:12 -05:00
parent 267bf289c4
commit 208bb2d72f
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2
2 changed files with 25 additions and 16 deletions

View file

@ -639,19 +639,16 @@ def proxy_file(response, env)
return
end
begin
if response.headers.includes_word?("Content-Encoding", "gzip")
Gzip::Writer.open(env.response) do |deflate|
copy_in_chunks(response.body_io, deflate)
end
elsif response.headers.includes_word?("Content-Encoding", "deflate")
Flate::Writer.open(env.response) do |deflate|
copy_in_chunks(response.body_io, deflate)
end
else
copy_in_chunks(response.body_io, env.response)
if response.headers.includes_word?("Content-Encoding", "gzip")
Gzip::Writer.open(env.response) do |deflate|
copy_in_chunks(response.body_io, deflate)
end
rescue ex
elsif response.headers.includes_word?("Content-Encoding", "deflate")
Flate::Writer.open(env.response) do |deflate|
copy_in_chunks(response.body_io, deflate)
end
else
copy_in_chunks(response.body_io, env.response)
end
end