Skip to content

Commit 8c81ab2

Browse files
jstanley0jeremyevans
authored andcommitted
don't invoke response block more than once due to retry
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
1 parent 21e226c commit 8c81ab2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/net/http.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,10 @@ def transport_request(req)
23502350
res
23512351
}
23522352
res.reading_body(@socket, req.response_body_permitted?) {
2353-
yield res if block_given?
2353+
if block_given?
2354+
count = max_retries # Don't restart in the middle of a download
2355+
yield res
2356+
end
23542357
}
23552358
rescue Net::OpenTimeout
23562359
raise

0 commit comments

Comments
 (0)