diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:50:01 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-08-17 07:50:01 +0000 |
commit | 9580200f7da99a5d1e2c3b35354b4972d1be9ea5 (patch) | |
tree | 15c29564b4d570da0d0a06c2c8a870344d4bd9a9 | |
parent | 59f1eaaf8fc39422f6ee8bbc666624e2ea754e7f (diff) |
merge revision(s) 51061,51063,51091: [Backport #11285]
* lib/net/http/response.rb (inflater): CONTENT_ENCODING can be upper
case. [ruby-core:69670] [Bug #11285] patched by Andy Chu
* test/net/http/test_httpresponse.rb
(HTTPResponseTest#test_read_body_content_encoding_deflate_uppercase):
fix a failure without zlib.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | lib/net/http/response.rb | 3 | ||||
-rw-r--r-- | test/net/http/test_httpresponse.rb | 28 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 42 insertions, 2 deletions
@@ -1,3 +1,14 @@ +Mon Aug 17 16:49:00 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com> + + * test/net/http/test_httpresponse.rb + (HTTPResponseTest#test_read_body_content_encoding_deflate_uppercase): + fix a failure without zlib. + +Mon Aug 17 16:49:00 2015 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/net/http/response.rb (inflater): CONTENT_ENCODING can be upper + case. [ruby-core:69670] [Bug #11285] patched by Andy Chu + Mon Aug 17 16:46:28 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm.c (m_core_hash_merge_ptr): copy the arguments to the machine diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index 9aaa0b3208..a36b3af36b 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -250,7 +250,8 @@ class Net::HTTPResponse return yield @socket unless @decode_content return yield @socket if self['content-range'] - case self['content-encoding'] + v = self['content-encoding'] + case v && v.downcase when 'deflate', 'gzip', 'x-gzip' then self.delete 'content-encoding' diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 0193a153e4..a9cd9f5d26 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -103,6 +103,34 @@ EOS end end + def test_read_body_content_encoding_deflate_uppercase + io = dummy_io(<<EOS) +HTTP/1.1 200 OK +Connection: close +Content-Encoding: DEFLATE +Content-Length: 13 + +x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15 +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 'hello', body + else + assert_equal 'DEFLATE', res['content-encoding'] + assert_equal "x\x9C\xCBH\xCD\xC9\xC9\a\x00\x06,\x02\x15", body + end + end + def test_read_body_content_encoding_deflate_chunked io = dummy_io(<<EOS) HTTP/1.1 200 OK @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.7" #define RUBY_RELEASE_DATE "2015-08-17" -#define RUBY_PATCHLEVEL 385 +#define RUBY_PATCHLEVEL 386 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 8 |