Skip to content

Commit

Permalink
don't invoke response block more than once due to retry
Browse files Browse the repository at this point in the history
If a socket error occurs while performing a streaming download via
the response block provided to transport_request, avoid calling
the response block again as this would result in duplicate data
received by the client.

fixes #86
  • Loading branch information
jstanley0 authored and jeremyevans committed Jan 5, 2024
1 parent 21e226c commit 8c81ab2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,10 @@ def transport_request(req)
res
}
res.reading_body(@socket, req.response_body_permitted?) {
yield res if block_given?
if block_given?
count = max_retries # Don't restart in the middle of a download
yield res
end
}
rescue Net::OpenTimeout
raise
Expand Down

0 comments on commit 8c81ab2

Please sign in to comment.