summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-10-26 11:43:28 -0400
committerOmar Roth <omarroth@protonmail.com>2019-10-26 11:51:23 -0400
commitbdeb325bad15ea32a3f039de39418a88a6ab6180 (patch)
tree1cb3b9b6a4dcb38135e9920ee3f0b5a6f2c4f957
parenta1225b6d0dfdfaadcde56e4745e8ad57f107142a (diff)
downloadinvidious-bdeb325bad15ea32a3f039de39418a88a6ab6180.tar.gz
invidious-bdeb325bad15ea32a3f039de39418a88a6ab6180.tar.bz2
invidious-bdeb325bad15ea32a3f039de39418a88a6ab6180.zip
Fix monkeypatch for HTTP::Client
-rw-r--r--src/invidious.cr2
-rw-r--r--src/invidious/helpers/handlers.cr4
-rw-r--r--src/invidious/helpers/utils.cr6
3 files changed, 8 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index cd6775a7..b0447865 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -5446,7 +5446,7 @@ get "/videoplayback" do |env|
client = make_client(URI.parse(host), region)
- response = HTTP::Client::Response.new(403)
+ response = HTTP::Client::Response.new(500)
5.times do
begin
response = client.head(url, headers)
diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr
index a3dfd062..5b60c1be 100644
--- a/src/invidious/helpers/handlers.cr
+++ b/src/invidious/helpers/handlers.cr
@@ -226,15 +226,15 @@ end
class HTTP::Client
private def handle_response(response)
- if @socket.is_a?(OpenSSL::SSL::Socket::Client)
+ if @socket.is_a?(OpenSSL::SSL::Socket::Client) && @host.ends_with? "googlevideo.com"
close unless response.keep_alive? || @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty?
+
if @socket.as(OpenSSL::SSL::Socket::Client).@in_buffer_rem.empty?
@socket = nil
end
else
close unless response.keep_alive?
end
-
response
end
end
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 8d4eff9b..7dd1adf3 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -1610,7 +1610,11 @@ struct HTTPPool
end
response = yield conn
- conn.unset_proxy
+
+ if region
+ conn.unset_proxy
+ end
+
response
rescue ex
conn = HTTPClient.new(url)