File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44require 'socket'
55require 'resolv'
66
7+ # Monkey-patch the HTTP.rb timeout class to avoid using a timeout block
8+ # around the Socket#open method, since we use our own timeout blocks inside
9+ # that method
10+ class HTTP ::Timeout ::PerOperation
11+ def connect ( socket_class , host , port , nodelay = false )
12+ @socket = socket_class . open ( host , port )
13+ @socket . setsockopt ( Socket ::IPPROTO_TCP , Socket ::TCP_NODELAY , 1 ) if nodelay
14+ end
15+ end
16+
717class Request
818 REQUEST_TARGET = '(request-target)'
919
@@ -94,7 +104,11 @@ def key_id
94104 end
95105
96106 def timeout
97- { connect : nil , read : 10 , write : 10 }
107+ # We enforce a 1s timeout on DNS resolving, 10s timeout on socket opening
108+ # and 5s timeout on the TLS handshake, meaning the worst case should take
109+ # about 16s in total
110+
111+ { connect : 5 , read : 10 , write : 10 }
98112 end
99113
100114 def http_client
You can’t perform that action at this time.
0 commit comments