summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-05-30 10:29:24 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-05-31 12:48:14 +0200
commit5a79d8e0507cd143100bf928a88a59a8b5a5bca6 (patch)
tree7e4c79ce85e071946051b4eec6d2c51b0d80b901 /lib
parent5b4b82b712e1d423fffd4f13fa1b797e304a3af5 (diff)
Fix error raised by Net::HTTPResponse#inflater if the block raises
* See https://bugs.ruby-lang.org/issues/13882#note-6
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3164
Diffstat (limited to 'lib')
-rw-r--r--lib/net/http/response.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 5a94f95694..08eaeb2cac 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -268,12 +268,13 @@ class Net::HTTPResponse
begin
yield inflate_body_io
+ success = true
ensure
- orig_err = $!
begin
inflate_body_io.finish
rescue => err
- raise orig_err || err
+ # Ignore #finish's error if there is an exception from yield
+ raise err if success
end
end
when 'none', 'identity' then