diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-28 04:51:37 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-28 04:51:37 +0000 |
commit | 8a7da58c0fe28af09ce0631d6ada79e47cc7b98f (patch) | |
tree | b555bd3f1c10aa26ad529cfa9c4655ffc1f0ed94 /test/net | |
parent | 1c85a648febde2176493b26130b08c742b3de305 (diff) | |
download | ruby-8a7da58c0fe28af09ce0631d6ada79e47cc7b98f.tar.gz |
* lib/net/http.rb: Retry HTTP requests for additional network errors.
Introduce OpenTimeout subclass of Timeout::Error. [Bug #6001]
* test/net/http/test_http.rb: Reduce timeout to 0.01s for faster test
* test/net/http/test_https.rb: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net')
-rw-r--r-- | test/net/http/test_http.rb | 14 | ||||
-rw-r--r-- | test/net/http/test_https.rb | 6 |
2 files changed, 9 insertions, 11 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index 411791626b..c4ca039237 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -195,13 +195,13 @@ module TestNetHTTP_version_1_1_methods 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 + # listen for connections... but deliberately do not read TCPServer.open('localhost', 0) {|server| port = server.addr[1] conn = Net::HTTP.new('localhost', port) - conn.read_timeout = 1 - conn.open_timeout = 1 + conn.read_timeout = 0.01 + conn.open_timeout = 0.01 th = Thread.new do assert_raise(Timeout::Error) { @@ -598,21 +598,19 @@ class TestNetHTTPKeepAlive < Test::Unit::TestCase assert_kind_of Net::HTTPResponse, res assert_kind_of String, res.body sleep 1.5 - assert_nothing_raised { - res = http.get('/') - } + res = http.get('/') assert_kind_of Net::HTTPResponse, res assert_kind_of String, res.body } end - def test_keep_alive_EOF + def test_keep_alive_server_close def @server.run(sock) sock.close end start {|http| - assert_raises(EOFError,Errno::ECONNRESET) { + assert_raises(EOFError, Errno::ECONNRESET, IOError) { res = http.get('/') } } diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index 4bb4f6d3a6..a911160fa0 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -115,11 +115,11 @@ class TestNetHTTPS < Test::Unit::TestCase conn = Net::HTTP.new('localhost', port) conn.use_ssl = true - conn.read_timeout = 1 - conn.open_timeout = 1 + conn.read_timeout = 0.01 + conn.open_timeout = 0.01 th = Thread.new do - assert_raise(Timeout::Error) { + assert_raise(Net::HTTP::OpenTimeout) { conn.get('/') } end |