mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/net-http] Replace Timeout.timeout in Net:HTTP#connect
Use Socket.tcp's connect_timeout option instead
753cae3bbc
This commit is contained in:
parent
e22626f08e
commit
8a2b7b79ee
1 changed files with 7 additions and 8 deletions
|
@ -981,14 +981,13 @@ module Net #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
D "opening connection to #{conn_addr}:#{conn_port}..."
|
D "opening connection to #{conn_addr}:#{conn_port}..."
|
||||||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
||||||
begin
|
begin
|
||||||
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout
|
||||||
rescue => e
|
rescue => e
|
||||||
|
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) #for compatibility with previous versions
|
||||||
raise e, "Failed to open TCP connection to " +
|
raise e, "Failed to open TCP connection to " +
|
||||||
"#{conn_addr}:#{conn_port} (#{e.message})"
|
"#{conn_addr}:#{conn_port} (#{e.message})"
|
||||||
end
|
end
|
||||||
}
|
|
||||||
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||||
D "opened"
|
D "opened"
|
||||||
if use_ssl?
|
if use_ssl?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue