mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/net-protocol] Add Net::Protocol::TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
* To find out efficiently if TCPSocket#initialize supports the open_timeout keyword argument. https://github.com/ruby/net-protocol/commit/738c06f950
This commit is contained in:
parent
4d7db86a79
commit
fda7019c80
Notes:
git
2025-12-26 02:02:29 +00:00
@ -54,6 +54,16 @@ module Net # :nodoc:
|
||||
s.connect
|
||||
end
|
||||
end
|
||||
|
||||
tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
|
||||
TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
|
||||
tcp_socket_parameters.include?([:key, :open_timeout])
|
||||
else
|
||||
# Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
|
||||
# See discussion in https://github.com/ruby/net-http/pull/224
|
||||
Socket.method(:tcp).parameters.include?([:key, :open_timeout])
|
||||
end
|
||||
private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user