mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Push potential fix for #578
This commit is contained in:
parent
818cd2454d
commit
ebfd7d2153
1 changed files with 24 additions and 0 deletions
|
@ -224,4 +224,28 @@ class HTTP::Client
|
||||||
|
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# See https://github.com/crystal-lang/crystal/issues/7843
|
||||||
|
private def socket
|
||||||
|
socket = @socket
|
||||||
|
return socket if socket
|
||||||
|
|
||||||
|
hostname = @host.starts_with?('[') && @host.ends_with?(']') ? @host[1..-2] : @host
|
||||||
|
socket = TCPSocket.new hostname, @port, @dns_timeout, @connect_timeout
|
||||||
|
socket.read_timeout = @read_timeout if @read_timeout
|
||||||
|
socket.sync = false
|
||||||
|
|
||||||
|
{% if !flag?(:without_openssl) %}
|
||||||
|
if tls = @tls
|
||||||
|
_socket = socket
|
||||||
|
begin
|
||||||
|
socket = OpenSSL::SSL::Socket::Client.new(socket, context: tls, sync_close: true, hostname: @host)
|
||||||
|
rescue
|
||||||
|
_socket.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
|
|
||||||
|
@socket = socket
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue