Skip to content

Commit da2aa1e

Browse files
committed
Raise Net::OpenTimeout when TCPSocket.open raises IO::TimeoutError.
With the changes in ruby/ruby#15602, `TCPSocket.open` now raises `IO::TimeoutError` when a user-specified timeout occurs. This change updates #connect to handle this case accordingly.
1 parent e8e37bb commit da2aa1e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/net/http.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
require 'net/protocol'
2424
require 'uri'
2525
require 'resolv'
26+
require 'io/wait'
2627
autoload :OpenSSL, 'openssl'
2728

2829
module Net #:nodoc:
@@ -1676,7 +1677,7 @@ def connect
16761677
begin
16771678
s = timeouted_connect(conn_addr, conn_port)
16781679
rescue => e
1679-
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
1680+
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) || e.is_a?(IO::TimeoutError) # for compatibility with previous versions
16801681
raise e, "Failed to open TCP connection to " +
16811682
"#{conn_addr}:#{conn_port} (#{e.message})"
16821683
end

0 commit comments

Comments
 (0)