ruby-changes:38980
From: naruse <ko1@a...>
Date: Mon, 29 Jun 2015 16:14:50 +0900 (JST)
Subject: [ruby-changes:38980] naruse:r51061 (trunk): * lib/net/http/response.rb (inflater): CONTENT_ENCODING can be upper
naruse 2015-06-29 16:14:31 +0900 (Mon, 29 Jun 2015) New Revision: 51061 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51061 Log: * lib/net/http/response.rb (inflater): CONTENT_ENCODING can be upper case. [ruby-core:69670] [Bug #11285] patched by Andy Chu Modified files: trunk/ChangeLog trunk/lib/net/http/response.rb trunk/test/net/http/test_httpresponse.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 51060) +++ ChangeLog (revision 51061) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jun 29 16:01:24 2015 NARUSE, Yui <naruse@r...> + + * lib/net/http/response.rb (inflater): CONTENT_ENCODING can be upper + case. [ruby-core:69670] [Bug #11285] patched by Andy Chu + Mon Jun 29 14:50:08 2015 Shugo Maeda <shugo@r...> * eval.c (add_activated_refinement): should not include the original Index: lib/net/http/response.rb =================================================================== --- lib/net/http/response.rb (revision 51060) +++ lib/net/http/response.rb (revision 51061) @@ -250,7 +250,7 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/lib/net/http/response.rb#L250 return yield @socket unless @decode_content return yield @socket if self['content-range'] - case self['content-encoding'] + case self['content-encoding'].downcase when 'deflate', 'gzip', 'x-gzip' then self.delete 'content-encoding' Index: test/net/http/test_httpresponse.rb =================================================================== --- test/net/http/test_httpresponse.rb (revision 51060) +++ test/net/http/test_httpresponse.rb (revision 51061) @@ -103,6 +103,34 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/net/http/test_httpresponse.rb#L103 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/