Invidious is an alternative front-end to YouTube
Proxy: Use connection pools for images (#4326)
Samantaz Fox9957da28dca3
diff --cc src/invidious/yt_backend/connection_pool.crindex 70b15f26,646d0d1a..c7c4c675--- a/src/invidious/yt_backend/connection_pool.cr+++ b/src/invidious/yt_backend/connection_pool.cr@@@ -82,15 -82,17 +86,30 @@@ def make_client(url : URI, region = nilendend+def make_configured_http_proxy_client+ # This method is only called when configuration for an HTTP proxy are set+ config_proxy = CONFIG.http_proxy.not_nil!++ return HTTP::Proxy::Client.new(+ config_proxy.host,+ config_proxy.port,++ username: config_proxy.user,+ password: config_proxy.password,+ )+end+++ # Fetches a HTTP pool for the specified subdomain of ytimg.com+ #+ # Creates a new one when the specified pool for the subdomain does not exist+ def get_ytimg_pool(subdomain)+ if pool = YTIMG_POOLS[subdomain]?+ return pool+ else+ LOGGER.info("ytimg_pool: Creating a new HTTP pool for \"https://#{subdomain}.ytimg.com\"")+ pool = YoutubeConnectionPool.new(URI.parse("https://#{subdomain}.ytimg.com"), capacity: CONFIG.pool_size)+ YTIMG_POOLS[subdomain] = pool++ return pool+ end+ end