From 9cf11b70ca2a271bcfd737d9fc580dd9fdfad20f Mon Sep 17 00:00:00 2001 From: ktsj Date: Sat, 1 Aug 2015 08:23:32 +0000 Subject: [PATCH] * 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/trunk@51465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 +++++ lib/net/http/response.rb | 1 + test/net/http/test_httpresponse.rb | 53 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/ChangeLog b/ChangeLog index 84dd1628d9..d077c1bc8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Aug 1 17:13:15 2015 Kazuki Tsujimoto + + * 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. + Sat Aug 1 17:05:18 2015 Kazuki Tsujimoto * lib/net/http/response.rb (Net::HTTPResponse#inflater): diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 253c5cbe98..126c22160d 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -359,6 +359,7 @@ class Net::HTTPResponse # Finishes the inflate stream. def finish + return if @inflate.total_in == 0 @inflate.finish end diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 6dd2a37e43..a86020581c 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(<