summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:39:18 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-17 08:39:18 +0000
commita5ffcdaeffdc05bfa63c7f9542791798f2878757 (patch)
treef695549bbcc06ee276bb294430145455d85c4183 /test
parentd3cd7b4813dcaf4022d8d70b8dd9f2bd17812d56 (diff)
merge revision(s) 46681,51464,51465: [Backport #11058]
* lib/net/http/response.rb (Net::HTTPResponse.each_response_header): raise first exception even if inflate_body_io.finish raises error. when begin block raises error, finish usually raises error too. * lib/net/http/response.rb (Net::HTTPResponse#inflater): fix TypeError. An exception object might be nil. [ruby-core:68846] [Bug #11058] * lib/net/http/response.rb (Net::HTTPResponse::Inflater#finish): fix a bug that empty gzipped response body causes Zlib::BufError. [ruby-core:68846] [Bug #11058] * test/net/http/test_httpresponse.rb: tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/http/test_httpresponse.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb
index a9cd9f5d26..404c7ae1fa 100644
--- a/test/net/http/test_httpresponse.rb
+++ b/test/net/http/test_httpresponse.rb
@@ -237,6 +237,59 @@ EOS
assert_equal "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x03", body
end
+ def test_read_body_content_encoding_deflate_empty_body
+ io = dummy_io(<<EOS)
+HTTP/1.1 200 OK
+Connection: close
+Content-Encoding: deflate
+Content-Length: 0
+
+EOS
+
+ res = Net::HTTPResponse.read_new(io)
+ res.decode_content = true
+
+ body = nil
+
+ res.reading_body io, true do
+ body = res.read_body
+ end
+
+ if Net::HTTP::HAVE_ZLIB
+ assert_equal nil, res['content-encoding']
+ assert_equal '', body
+ else
+ assert_equal 'deflate', res['content-encoding']
+ assert_equal '', body
+ end
+ end
+
+ def test_read_body_content_encoding_deflate_empty_body_no_length
+ io = dummy_io(<<EOS)
+HTTP/1.1 200 OK
+Connection: close
+Content-Encoding: deflate
+
+EOS
+
+ res = Net::HTTPResponse.read_new(io)
+ res.decode_content = true
+
+ body = nil
+
+ res.reading_body io, true do
+ body = res.read_body
+ end
+
+ if Net::HTTP::HAVE_ZLIB
+ assert_equal nil, res['content-encoding']
+ assert_equal '', body
+ else
+ assert_equal 'deflate', res['content-encoding']
+ assert_equal '', body
+ end
+ end
+
def test_read_body_string
io = dummy_io(<<EOS)
HTTP/1.1 200 OK