mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-02-17 14:06:14 +00:00
Add header duplication for feeds
This commit is contained in:
@@ -13,7 +13,7 @@ struct YoutubeConnectionPool
|
||||
@pool = build_pool()
|
||||
end
|
||||
|
||||
def client(&)
|
||||
def client(env : HTTP::Server::Context? = nil, headers_to_duplicate : Array(String)? = nil, &)
|
||||
conn = pool.checkout
|
||||
# Proxy needs to be reinstated every time we get a client from the pool
|
||||
conn.proxy = make_configured_http_proxy_client() if CONFIG.http_proxy
|
||||
@@ -29,6 +29,20 @@ struct YoutubeConnectionPool
|
||||
pool.release(conn)
|
||||
end
|
||||
|
||||
# Shit way do not use do not replicate this is horrible because how blocks work
|
||||
if env && headers_to_duplicate
|
||||
if response.is_a?(HTTP::Client::Response)
|
||||
youtube_response_headers = response.headers
|
||||
if youtube_response_headers
|
||||
headers_to_duplicate.each do |header|
|
||||
if header_value = youtube_response_headers[header]?
|
||||
env.response.headers[header] = header_value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user