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

ruby-changes:44523

From: naruse <ko1@a...>
Date: Sat, 5 Nov 2016 23:08:21 +0900 (JST)
Subject: [ruby-changes:44523] naruse:r56596 (trunk): * lib/net/http.rb (transport_request): other than HTTPContinue

naruse	2016-11-05 23:08:16 +0900 (Sat, 05 Nov 2016)

  New Revision: 56596

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

  Log:
    * lib/net/http.rb (transport_request): other than HTTPContinue
      in 1xx (HTTPInformation) also needs to continue. [Bug #12890]

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/http.rb
    trunk/test/net/http/test_http.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56595)
+++ ChangeLog	(revision 56596)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Nov  5 23:03:54 2016  NARUSE, Yui  <naruse@r...>
+
+	* lib/net/http.rb (transport_request): other than HTTPContinue
+	  in 1xx (HTTPInformation) also needs to continue. [Bug #12890]
+
 Sat Nov  5 22:51:06 2016  Tanaka Akira  <akr@f...>
 
 	* lib/time.rb (make_time): "now" argument as nil works again.
Index: lib/net/http.rb
===================================================================
--- lib/net/http.rb	(revision 56595)
+++ lib/net/http.rb	(revision 56596)
@@ -1425,7 +1425,7 @@ module Net   #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1425
           begin
             res = HTTPResponse.read_new(@socket)
             res.decode_content = req.decode_content
-          end while res.kind_of?(HTTPContinue)
+          end while res.kind_of?(HTTPInformation)
 
           res.uri = req.uri
 
Index: test/net/http/test_http.rb
===================================================================
--- test/net/http/test_http.rb	(revision 56595)
+++ test/net/http/test_http.rb	(revision 56596)
@@ -894,6 +894,39 @@ class TestNetHTTPContinue < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L894
   end
 end
 
+class TestNetHTTPSwitchingProtocols < Test::Unit::TestCase
+  CONFIG = {
+    'host' => '127.0.0.1',
+    'proxy_host' => nil,
+    'proxy_port' => nil,
+    'chunked' => true,
+  }
+
+  include TestNetHTTPUtils
+
+  def logfile
+    @debug = StringIO.new('')
+  end
+
+  def mount_proc(&block)
+    @server.mount('/continue', WEBrick::HTTPServlet::ProcHandler.new(block.to_proc))
+  end
+
+  def test_info
+    mount_proc {|req, res|
+      req.instance_variable_get(:@socket) << "HTTP/1.1 101 Switching Protocols\r\n\r\n"
+      res.body = req.query['body']
+    }
+    start {|http|
+      http.continue_timeout = 0.2
+      http.request_post('/continue', 'body=BODY') {|res|
+        assert_equal('BODY', res.read_body)
+      }
+    }
+    assert_match(/HTTP\/1.1 101 Switching Protocols/, @debug.string)
+  end
+end
+
 class TestNetHTTPKeepAlive < Test::Unit::TestCase
   CONFIG = {
     'host' => '127.0.0.1',

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

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