diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-12 07:26:18 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-12 07:26:18 +0000 |
commit | ef0736604a327e30568ea97ca07637c7d144544e (patch) | |
tree | b5eed048140003a7762e183b6b05034e9bad5115 /test/net/http/test_https.rb | |
parent | 6c977786187b4287c53c3df1de2a20df89feab72 (diff) | |
download | ruby-ef0736604a327e30568ea97ca07637c7d144544e.tar.gz |
* 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
Diffstat (limited to 'test/net/http/test_https.rb')
-rw-r--r-- | test/net/http/test_https.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index 95c63da750..8da7090c68 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -2,6 +2,7 @@ require "test/unit" begin require 'net/https' require 'stringio' + require 'timeout' require File.expand_path("../../openssl/utils", File.dirname(__FILE__)) require File.expand_path("utils", File.dirname(__FILE__)) rescue LoadError @@ -104,4 +105,25 @@ class TestNetHTTPS < Test::Unit::TestCase } assert_match(/hostname does not match/, ex.message) 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) |