diff options
Diffstat (limited to 'test/net')
-rw-r--r-- | test/net/http/test_http.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index cfdf62191f..052c3ef558 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -896,6 +896,23 @@ class TestNetHTTPKeepAlive < Test::Unit::TestCase } end + def test_server_closed_connection_auto_reconnect + start {|http| + res = http.get('/') + http.keep_alive_timeout = 5 + assert_kind_of Net::HTTPResponse, res + assert_kind_of String, res.body + sleep 1.5 + assert_nothing_raised { + # Net::HTTP should detect the closed connection before attempting the + # request, since post requests cannot be retried. + res = http.post('/', 'query=foo', 'content-type' => 'application/x-www-form-urlencoded') + } + assert_kind_of Net::HTTPResponse, res + assert_kind_of String, res.body + } + end + def test_keep_alive_get_auto_retry start {|http| res = http.get('/') |