From 7a852aa87695edf792e958076f48005c73dd5037 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Mon, 12 Dec 2022 16:40:15 -0700 Subject: [PATCH] Allow HTTP-exclusive proxies for all requests Proxies that only support HTTP were causing request timeouts due to an invalid upgrade to HTTPS when creating the request. This update restores the ability to have an HTTP-only proxy for all requests. Fixes #906 --- app/request.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/request.py b/app/request.py index 7bfbbad..571ba51 100644 --- a/app/request.py +++ b/app/request.py @@ -209,19 +209,13 @@ class Request: proxy_pass = os.environ.get('WHOOGLE_PROXY_PASS', '') auth_str = '' if proxy_user: - auth_str = proxy_user + ':' + proxy_pass - self.proxies = { - 'https': proxy_type + '://' + - ((auth_str + '@') if auth_str else '') + proxy_path, - } + auth_str = f'{proxy_user}:{proxy_pass}@' - # Need to ensure both HTTP and HTTPS are in the proxy dict, - # regardless of underlying protocol - if proxy_type == 'https': - self.proxies['http'] = self.proxies['https'].replace( - 'https', 'http') - else: - self.proxies['http'] = self.proxies['https'] + proxy_str = f'{proxy_type}://{auth_str}{proxy_path}' + self.proxies = { + 'https': proxy_str, + 'http': proxy_str + } else: self.proxies = { 'http': 'socks5://127.0.0.1:9050',