Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
34de90c4
Commit
34de90c4
authored
6 years ago
by
Eugen Rochko
Browse files
Options
Download
Email Patches
Plain Diff
Fix TLS handshake timeout not being enforced (#9381)
Follow-up to #9329
parent
442f3355
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/request.rb
+15
-1
app/lib/request.rb
with
15 additions
and
1 deletion
+15
-1
app/lib/request.rb
+
15
-
1
View file @
34de90c4
...
...
@@ -4,6 +4,16 @@ require 'ipaddr'
require
'socket'
require
'resolv'
# Monkey-patch the HTTP.rb timeout class to avoid using a timeout block
# around the Socket#open method, since we use our own timeout blocks inside
# that method
class
HTTP::Timeout::PerOperation
def
connect
(
socket_class
,
host
,
port
,
nodelay
=
false
)
@socket
=
socket_class
.
open
(
host
,
port
)
@socket
.
setsockopt
(
Socket
::
IPPROTO_TCP
,
Socket
::
TCP_NODELAY
,
1
)
if
nodelay
end
end
class
Request
REQUEST_TARGET
=
'(request-target)'
...
...
@@ -95,7 +105,11 @@ class Request
end
def
timeout
{
connect:
nil
,
read:
10
,
write:
10
}
# We enforce a 1s timeout on DNS resolving, 10s timeout on socket opening
# and 5s timeout on the TLS handshake, meaning the worst case should take
# about 16s in total
{
connect:
5
,
read:
10
,
write:
10
}
end
def
http_client
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment