diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-12-16 10:40:29 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-12-16 10:48:39 +0900 |
| commit | 06051311d828bead3922ac5766822000c011e5db (patch) | |
| tree | f8e673b2225a6bdcabcfa95722acabea58b4b96d /lib | |
| parent | 359653658e604c075e3eca73e20b02d0d46bd0ef (diff) | |
merge revision(s) 9d58f9382893a71d8badad605879c0120915fbee:
[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
---
lib/net/http/response.rb | 3 ++-
test/net/http/test_httpresponse.rb | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
Diffstat (limited to 'lib')
| -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) |
