* lib/net/http.rb (Net::HTTP#connect): makes it timeout during
SSL handshake too. [ruby-core:34203] Patch by Marc Slemko. * test/net/http/test_http.rb (TestNetHTTP_v1_2#test_timeout_during_HTTP_session): test for [ruby-core:34203] * test/net/http/test_https.rb (TestNetHTTPS#test_timeout_during_SSL_handshake): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6c97778618
commit
ef0736604a
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Wed Jan 12 16:25:12 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
|
* lib/net/http.rb (Net::HTTP#connect): makes it timeout during
|
||||||
|
SSL handshake too. [ruby-core:34203]
|
||||||
|
Patch by Marc Slemko.
|
||||||
|
|
||||||
|
* test/net/http/test_http.rb (TestNetHTTP_v1_2#test_timeout_during_HTTP_session):
|
||||||
|
test for [ruby-core:34203]
|
||||||
|
|
||||||
|
* test/net/http/test_https.rb (TestNetHTTPS#test_timeout_during_SSL_handshake):
|
||||||
|
ditto.
|
||||||
|
|
||||||
Wed Jan 12 16:24:53 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
Wed Jan 12 16:24:53 2011 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
* ext/readline/extconf.rb: new checks for RL_PROMPT_START_IGNORE
|
* ext/readline/extconf.rb: new checks for RL_PROMPT_START_IGNORE
|
||||||
|
@ -767,6 +767,7 @@ module Net #:nodoc:
|
|||||||
@socket.read_timeout = @read_timeout
|
@socket.read_timeout = @read_timeout
|
||||||
@socket.debug_output = @debug_output
|
@socket.debug_output = @debug_output
|
||||||
if use_ssl?
|
if use_ssl?
|
||||||
|
begin
|
||||||
if proxy?
|
if proxy?
|
||||||
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
@socket.writeline sprintf('CONNECT %s:%s HTTP/%s',
|
||||||
@address, @port, HTTPVersion)
|
@address, @port, HTTPVersion)
|
||||||
@ -779,10 +780,15 @@ module Net #:nodoc:
|
|||||||
@socket.writeline ''
|
@socket.writeline ''
|
||||||
HTTPResponse.read_new(@socket).value
|
HTTPResponse.read_new(@socket).value
|
||||||
end
|
end
|
||||||
s.connect
|
timeout(@open_timeout) { s.connect }
|
||||||
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||||||
s.post_connection_check(@address)
|
s.post_connection_check(@address)
|
||||||
end
|
end
|
||||||
|
rescue => exception
|
||||||
|
D "Conn close because of connect error #{exception}"
|
||||||
|
@socket.close if @socket and not @socket.closed?
|
||||||
|
raise exception
|
||||||
|
end
|
||||||
end
|
end
|
||||||
on_connect
|
on_connect
|
||||||
end
|
end
|
||||||
|
@ -182,6 +182,25 @@ module TestNetHTTP_version_1_1_methods
|
|||||||
assert_equal data, res.entity
|
assert_equal data, res.entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_timeout_during_HTTP_session
|
||||||
|
bug4246 = "expected the HTTP session to have timed out but have not. c.f. [ruby-core:34203]"
|
||||||
|
|
||||||
|
# listen for connections... but deliberately do not complete SSL handshake
|
||||||
|
TCPServer.open(0) {|server|
|
||||||
|
port = server.addr[1]
|
||||||
|
|
||||||
|
conn = Net::HTTP.new('localhost', port)
|
||||||
|
conn.read_timeout = 1
|
||||||
|
conn.open_timeout = 1
|
||||||
|
|
||||||
|
th = Thread.new do
|
||||||
|
assert_raise(Timeout::Error) {
|
||||||
|
conn.get('/')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
assert th.join(10), bug4246
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ require "test/unit"
|
|||||||
begin
|
begin
|
||||||
require 'net/https'
|
require 'net/https'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
require 'timeout'
|
||||||
require File.expand_path("../../openssl/utils", File.dirname(__FILE__))
|
require File.expand_path("../../openssl/utils", File.dirname(__FILE__))
|
||||||
require File.expand_path("utils", File.dirname(__FILE__))
|
require File.expand_path("utils", File.dirname(__FILE__))
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
@ -104,4 +105,25 @@ class TestNetHTTPS < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
assert_match(/hostname does not match/, ex.message)
|
assert_match(/hostname does not match/, ex.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_timeout_during_SSL_handshake
|
||||||
|
bug4246 = "expected the SSL connection to have timed out but have not. [ruby-core:34203]"
|
||||||
|
|
||||||
|
# listen for connections... but deliberately do not complete SSL handshake
|
||||||
|
TCPServer.open(0) {|server|
|
||||||
|
port = server.addr[1]
|
||||||
|
|
||||||
|
conn = Net::HTTP.new('localhost', port)
|
||||||
|
conn.use_ssl = true
|
||||||
|
conn.read_timeout = 1
|
||||||
|
conn.open_timeout = 1
|
||||||
|
|
||||||
|
th = Thread.new do
|
||||||
|
assert_raise(Timeout::Error) {
|
||||||
|
conn.get('/')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
assert th.join(10), bug4246
|
||||||
|
}
|
||||||
|
end
|
||||||
end if defined?(OpenSSL)
|
end if defined?(OpenSSL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user