From 59806dd439f512d6d5b40ea191a224d3198c9042 Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 5 Nov 2016 14:08:16 +0000 Subject: * lib/net/http.rb (transport_request): other than HTTPContinue in 1xx (HTTPInformation) also needs to continue. [Bug #12890] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/http.rb | 2 +- test/net/http/test_http.rb | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index de5d3d1100..d305370b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Nov 5 23:03:54 2016 NARUSE, Yui + + * 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 * lib/time.rb (make_time): "now" argument as nil works again. diff --git a/lib/net/http.rb b/lib/net/http.rb index 25d7dae873..6031bcaaeb 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1425,7 +1425,7 @@ module Net #:nodoc: 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 diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 4c45e57503..9dd665c530 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -894,6 +894,39 @@ class TestNetHTTPContinue < Test::Unit::TestCase 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', -- cgit v1.2.3