[ruby/net-http] Replace Timeout.timeout in Net:HTTP#connect

Use Socket.tcp's connect_timeout option instead

https://github.com/ruby/net-http/commit/753cae3bbc
This commit is contained in:
mohamed 2021-01-13 14:03:14 -08:00 коммит произвёл Hiroshi SHIBATA
Родитель e22626f08e
Коммит 8a2b7b79ee
1 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -981,14 +981,13 @@ module Net #:nodoc:
end
D "opening connection to #{conn_addr}:#{conn_port}..."
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) {
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
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) #for compatibility with previous versions
raise e, "Failed to open TCP connection to " +
"#{conn_addr}:#{conn_port} (#{e.message})"
end
}
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
D "opened"
if use_ssl?