diff options
author | Brian Hawley <brian_hawley@yahoo.com> | 2022-09-22 16:08:59 -0700 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-10-05 07:11:52 +0000 |
commit | 9d58f9382893a71d8badad605879c0120915fbee (patch) | |
tree | b43ad415a4b5c7ff8790f821ea5e1c6bdb466e8c /lib/net | |
parent | d088b9f77db962114dfab387e044bcf0f013c454 (diff) | |
download | ruby-9d58f9382893a71d8badad605879c0120915fbee.tar.gz |
[ruby/net-http] Net::HTTPResponse nil checking
Fix nil handling in read_body and stream_check.
Fixes: #70
https://github.com/ruby/net-http/commit/36f916ac18
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/http/response.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 192fa2c749..40de963868 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -366,6 +366,7 @@ class Net::HTTPResponse @body = nil end @read = true + return if @body.nil? case enc = @body_encoding when Encoding, false, nil @@ -639,7 +640,7 @@ class Net::HTTPResponse end def stream_check - raise IOError, 'attempt to read body out of block' if @socket.closed? + raise IOError, 'attempt to read body out of block' if @socket.nil? || @socket.closed? end def procdest(dest, block) |