summaryrefslogtreecommitdiff
path: root/lib/net
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2024-01-05 08:51:32 -0800
committergit <[email protected]>2024-01-05 16:51:37 +0000
commit4d03140009044096ac1903281682f357ab4acf98 (patch)
tree9230f11f51931c4240cdaa43b68bd9278621aed6 /lib/net
parent37657c79b66994147e41f31139ceb9c0c840868f (diff)
[ruby/net-http] 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 https://github.com/ruby/net-http/pull/86 Fixes https://github.com/ruby/net-http/pull/87 Fixes [Bug #11526] https://github.com/ruby/net-http/commit/114d01b092 Co-authored-by: Jeremy Stanley <[email protected]>
Diffstat (limited to 'lib/net')
-rw-r--r--lib/net/http.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 387df4b8f4..d143f3b30f 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -2350,7 +2350,10 @@ module Net #:nodoc:
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