[前][次][番号順一覧][スレッド一覧]

ruby-changes:39474

From: nagachika <ko1@a...>
Date: Thu, 13 Aug 2015 01:23:51 +0900 (JST)
Subject: [ruby-changes:39474] nagachika:r51555 (ruby_2_2): merge revision(s) 51464, 51465: [Backport #11058]

nagachika	2015-08-13 01:23:30 +0900 (Thu, 13 Aug 2015)

  New Revision: 51555

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51555

  Log:
    merge revision(s) 51464,51465: [Backport #11058]
    
    * 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.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/lib/net/http/response.rb
    branches/ruby_2_2/test/net/http/test_httpresponse.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 51554)
+++ ruby_2_2/ChangeLog	(revision 51555)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Thu Aug 13 01:03:13 2015  Kazuki Tsujimoto  <kazuki@c...>
+
+	* 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.
+
+Thu Aug 13 01:03:13 2015  Kazuki Tsujimoto  <kazuki@c...>
+
+	* lib/net/http/response.rb (Net::HTTPResponse#inflater):
+	  fix TypeError. An exception object might be nil.
+	  [ruby-core:68846] [Bug #11058]
+
 Thu Aug 13 00:03:24 2015  Aaron Patterson <tenderlove@r...>
 
 	* .travis.yml: update libssl before running tests. 
Index: ruby_2_2/lib/net/http/response.rb
===================================================================
--- ruby_2_2/lib/net/http/response.rb	(revision 51554)
+++ ruby_2_2/lib/net/http/response.rb	(revision 51555)
@@ -260,11 +260,11 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/net/http/response.rb#L260
       begin
         yield inflate_body_io
       ensure
-        e = $!
+        orig_err = $!
         begin
           inflate_body_io.finish
-        rescue
-          raise e
+        rescue => err
+          raise orig_err || err
         end
       end
     when 'none', 'identity' then
@@ -359,6 +359,7 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/net/http/response.rb#L359
     # Finishes the inflate stream.
 
     def finish
+      return if @inflate.total_in == 0
       @inflate.finish
     end
 
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 51554)
+++ ruby_2_2/version.h	(revision 51555)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.3"
 #define RUBY_RELEASE_DATE "2015-08-13"
-#define RUBY_PATCHLEVEL 161
+#define RUBY_PATCHLEVEL 162
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_2/test/net/http/test_httpresponse.rb
===================================================================
--- ruby_2_2/test/net/http/test_httpresponse.rb	(revision 51554)
+++ ruby_2_2/test/net/http/test_httpresponse.rb	(revision 51555)
@@ -237,6 +237,59 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/net/http/test_httpresponse.rb#L237
     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

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r51464-51465


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]