summaryrefslogtreecommitdiff
path: root/test/net/http/test_http.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-06 08:03:47 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-06 08:03:47 +0000
commitbd7c46a7aa8b4f44ef683e22f469033b96d3dd5f (patch)
tree8100dd93ab2032f3d61f3b82e80b0d37f0ae2f82 /test/net/http/test_http.rb
parentacc48fce30b413c158d06e5578ac73b07ed60b69 (diff)
Introduce write_timeout to Net::HTTP [Feature #13396]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http/test_http.rb')
-rw-r--r--test/net/http/test_http.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index d3c2aecb9f..778bf01f8f 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -529,6 +529,30 @@ module TestNetHTTP_version_1_1_methods
assert_equal data, res.entity
end
+ def test_timeout_during_HTTP_session_write
+ bug4246 = "expected the HTTP session to have timed out but have not. c.f. [ruby-core:34203]"
+
+ th = nil
+ # listen for connections... but deliberately do not read
+ TCPServer.open('localhost', 0) {|server|
+ port = server.addr[1]
+
+ conn = Net::HTTP.new('localhost', port)
+ conn.write_timeout = 0.01
+ conn.open_timeout = 0.1
+
+ th = Thread.new do
+ assert_raise(Net::WriteTimeout) {
+ conn.post('/', "a"*5_000_000)
+ }
+ end
+ assert th.join(10), bug4246
+ }
+ ensure
+ th.kill
+ th.join
+ end
+
def test_timeout_during_HTTP_session
bug4246 = "expected the HTTP session to have timed out but have not. c.f. [ruby-core:34203]"