mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-20 21:24:21 -05:00
Allow storyboard queries with QUIC disabled
This commit is contained in:
parent
c3747c2d49
commit
6b8450558d
@ -78,7 +78,9 @@ module Invidious::Routes::Images
|
|||||||
|
|
||||||
headers = HTTP::Headers.new
|
headers = HTTP::Headers.new
|
||||||
|
|
||||||
|
{% unless flag?(:disable_quic) %}
|
||||||
headers[":authority"] = "#{authority}.ytimg.com"
|
headers[":authority"] = "#{authority}.ytimg.com"
|
||||||
|
{% end %}
|
||||||
|
|
||||||
REQUEST_HEADERS_WHITELIST.each do |header|
|
REQUEST_HEADERS_WHITELIST.each do |header|
|
||||||
if env.request.headers[header]?
|
if env.request.headers[header]?
|
||||||
@ -86,8 +88,7 @@ module Invidious::Routes::Images
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
request_proc = ->(response : HTTP::Client::Response) {
|
||||||
YT_POOL.client &.get(url, headers) do |response|
|
|
||||||
env.response.status_code = response.status_code
|
env.response.status_code = response.status_code
|
||||||
response.headers.each do |key, value|
|
response.headers.each do |key, value|
|
||||||
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
||||||
@ -99,12 +100,29 @@ module Invidious::Routes::Images
|
|||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
if response.status_code >= 300
|
if response.status_code >= 300
|
||||||
env.response.headers.delete("Transfer-Encoding")
|
return env.response.headers.delete("Transfer-Encoding")
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
proxy_file(response, env)
|
proxy_file(response, env)
|
||||||
|
}
|
||||||
|
|
||||||
|
begin
|
||||||
|
{% unless flag?(:disable_quic) %}
|
||||||
|
if CONFIG.use_quic
|
||||||
|
YT_POOL.client &.get(url, headers) do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
HTTP::Client.get("#{authority}.ytimg.com#{url}") do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{% else %}
|
||||||
|
# This can likely be optimized into a (small) pool sometime in the future.
|
||||||
|
HTTP::Client.get("#{authority}.ytimg.com#{url}") do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
rescue ex
|
rescue ex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -113,18 +131,27 @@ module Invidious::Routes::Images
|
|||||||
def self.s_p_image(env)
|
def self.s_p_image(env)
|
||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
name = env.params.url["name"]
|
name = env.params.url["name"]
|
||||||
|
|
||||||
url = env.request.resource
|
url = env.request.resource
|
||||||
|
|
||||||
headers = HTTP::Headers{":authority" => "i9.ytimg.com"}
|
headers = (
|
||||||
|
{% unless flag?(:disable_quic) %}
|
||||||
|
if CONFIG.use_quic
|
||||||
|
HTTP::Headers{":authority" => "i9.ytimg.com"}
|
||||||
|
else
|
||||||
|
HTTP::Headers.new
|
||||||
|
end
|
||||||
|
{% else %}
|
||||||
|
HTTP::Headers.new
|
||||||
|
{% end %}
|
||||||
|
)
|
||||||
|
|
||||||
REQUEST_HEADERS_WHITELIST.each do |header|
|
REQUEST_HEADERS_WHITELIST.each do |header|
|
||||||
if env.request.headers[header]?
|
if env.request.headers[header]?
|
||||||
headers[header] = env.request.headers[header]
|
headers[header] = env.request.headers[header]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
request_proc = ->(response : HTTP::Client::Response) {
|
||||||
YT_POOL.client &.get(url, headers) do |response|
|
|
||||||
env.response.status_code = response.status_code
|
env.response.status_code = response.status_code
|
||||||
response.headers.each do |key, value|
|
response.headers.each do |key, value|
|
||||||
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
||||||
@ -135,12 +162,29 @@ module Invidious::Routes::Images
|
|||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
if response.status_code >= 300 && response.status_code != 404
|
if response.status_code >= 300 && response.status_code != 404
|
||||||
env.response.headers.delete("Transfer-Encoding")
|
return env.response.headers.delete("Transfer-Encoding")
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
proxy_file(response, env)
|
proxy_file(response, env)
|
||||||
|
}
|
||||||
|
|
||||||
|
begin
|
||||||
|
{% unless flag?(:disable_quic) %}
|
||||||
|
if CONFIG.use_quic
|
||||||
|
YT_POOL.client &.get(url, headers) do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
HTTP::Client.get("i9.ytimg.com#{url}") do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{% else %}
|
||||||
|
# This can likely be optimized into a (small) pool sometime in the future.
|
||||||
|
HTTP::Client.get("i9.ytimg.com#{url}") do |resp|
|
||||||
|
return request_proc.call(resp)
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
rescue ex
|
rescue ex
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user