1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix undefined method 'dump' for nil:NilClass (NoMethodError)

Patch by: Dmitry Vorotilin <d.vorotilin@gmail.com> (@route)
Signed-off-by: Akira Matsuda <ronnie@dio.jp>

closes #1475

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
a_matsuda 2016-11-08 20:25:44 +00:00
parent d0a6339903
commit 39edad0380
2 changed files with 19 additions and 1 deletions

View file

@ -117,7 +117,9 @@ class Net::HTTPResponse
end
def error! #:nodoc:
raise error_type().new(@code + ' ' + @message.dump, self)
message = @code
message += ' ' + @message.dump if @message
raise error_type().new(message, self)
end
def error_type #:nodoc:

View file

@ -385,6 +385,22 @@ EOS
assert_equal(nil, res.message)
end
def test_raises_exception_with_missing_reason
io = dummy_io(<<EOS)
HTTP/1.1 404
Content-Length: 5
Connection: close
hello
EOS
res = Net::HTTPResponse.read_new(io)
assert_equal(nil, res.message)
assert_raise Net::HTTPServerException do
res.error!
end
end
private
def dummy_io(str)