mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-09 15:02:14 +05:30
Remove useless proc usage in images.cr
This commit is contained in:
parent
003c6f81dc
commit
75b68618ab
@ -41,14 +41,10 @@ module Invidious::Routes::Images
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A callable proc to be used inside #proxy_image
|
|
||||||
callable_proc = ->(env : HTTP::Server::Context) {
|
|
||||||
env.response.headers["Connection"] = "close"
|
|
||||||
}
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
get_ytimg_pool(authority).client &.get(url, headers) do |resp|
|
get_ytimg_pool(authority).client &.get(url, headers) do |resp|
|
||||||
return self.proxy_image(env, resp, callable_proc: callable_proc)
|
env.response.headers["Connection"] = "close"
|
||||||
|
return self.proxy_image(env, resp)
|
||||||
end
|
end
|
||||||
rescue ex
|
rescue ex
|
||||||
end
|
end
|
||||||
@ -138,7 +134,7 @@ module Invidious::Routes::Images
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def self.proxy_image(env, response, callable_proc = nil)
|
private def self.proxy_image(env, 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)
|
||||||
@ -148,10 +144,6 @@ module Invidious::Routes::Images
|
|||||||
|
|
||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
if callable_proc
|
|
||||||
callable_proc.call(env)
|
|
||||||
end
|
|
||||||
|
|
||||||
if response.status_code >= 300
|
if response.status_code >= 300
|
||||||
return env.response.headers.delete("Transfer-Encoding")
|
return env.response.headers.delete("Transfer-Encoding")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user