Skip to content

Commit f64109e

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 f64109e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/net/http.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,9 @@ def connect
16761676
begin
16771677
s = timeouted_connect(conn_addr, conn_port)
16781678
rescue => e
1679-
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
1679+
if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
1680+
e = Net::OpenTimeout.new(e)
1681+
end
16801682
raise e, "Failed to open TCP connection to " +
16811683
"#{conn_addr}:#{conn_port} (#{e.message})"
16821684
end

0 commit comments

Comments
 (0)