diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 00:46:07 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-31 00:46:07 +0000 |
commit | 69a1db96fe63ff3071cb3d272675a1d0470aab01 (patch) | |
tree | ef9aca397ca57fd1376d44309a54e69717a0c1cc /lib/net/http.rb | |
parent | f964fd3fa5070b95cb412cb529b47e168c0af25a (diff) |
lib/net/http.rb: use connect_timeout instead of Timeout
lib/net/pop.rb: ditto
lib/net/ftp.rb: ditto
lib/net/smtp.rb: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/http.rb')
-rw-r--r-- | lib/net/http.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/net/http.rb b/lib/net/http.rb index 31cbb7a866..8ba15e4054 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -942,14 +942,15 @@ module Net #:nodoc: end D "opening connection to #{conn_address}:#{conn_port}..." - s = Timeout.timeout(@open_timeout, Net::OpenTimeout) { - begin - TCPSocket.open(conn_address, conn_port, @local_host, @local_port) - rescue => e - raise e, "Failed to open TCP connection to " + - "#{conn_address}:#{conn_port} (#{e.message})" - end - } + begin + s = Socket.tcp(conn_address, conn_port, @local_host, @local_port, connect_timeout: @open_timeout) + rescue Errno::ETIMEDOUT => e + raise Net::OpenTimeout, "Failed to open TCP connection to " + + "#{conn_address}:#{conn_port} (#{e.message})" + rescue => e + raise e, "Failed to open TCP connection to " + + "#{conn_address}:#{conn_port} (#{e.message})" + end s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) D "opened" if use_ssl? |