Skip to content

Commit 3d4181c

Browse files
authored
Merge pull request #43 from eregon/add_tcpsocket_has_open_timeout_constant
Add Net::Protocol::TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
2 parents e376022 + c847e49 commit 3d4181c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
needs: ruby-verions
1313
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
ruby: ${{ fromJson(needs.ruby-verions.outputs.versions) }}
1718
os: [ ubuntu-latest, macos-latest, windows-latest ]

lib/net/protocol.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ def ssl_socket_connect(s, timeout)
5454
s.connect
5555
end
5656
end
57+
58+
tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
59+
TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
60+
tcp_socket_parameters.include?([:key, :open_timeout])
61+
else
62+
# Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
63+
# See discussion in https://github.com/ruby/net-http/pull/224
64+
Socket.method(:tcp).parameters.include?([:key, :open_timeout])
65+
end
66+
private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
5767
end
5868

5969

0 commit comments

Comments
 (0)