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 #906main
parent
8fbbdf2cec
commit
7a852aa876
|
@ -209,19 +209,13 @@ class Request:
|
||||||
proxy_pass = os.environ.get('WHOOGLE_PROXY_PASS', '')
|
proxy_pass = os.environ.get('WHOOGLE_PROXY_PASS', '')
|
||||||
auth_str = ''
|
auth_str = ''
|
||||||
if proxy_user:
|
if proxy_user:
|
||||||
auth_str = proxy_user + ':' + proxy_pass
|
auth_str = f'{proxy_user}:{proxy_pass}@'
|
||||||
self.proxies = {
|
|
||||||
'https': proxy_type + '://' +
|
|
||||||
((auth_str + '@') if auth_str else '') + proxy_path,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Need to ensure both HTTP and HTTPS are in the proxy dict,
|
proxy_str = f'{proxy_type}://{auth_str}{proxy_path}'
|
||||||
# regardless of underlying protocol
|
self.proxies = {
|
||||||
if proxy_type == 'https':
|
'https': proxy_str,
|
||||||
self.proxies['http'] = self.proxies['https'].replace(
|
'http': proxy_str
|
||||||
'https', 'http')
|
}
|
||||||
else:
|
|
||||||
self.proxies['http'] = self.proxies['https']
|
|
||||||
else:
|
else:
|
||||||
self.proxies = {
|
self.proxies = {
|
||||||
'http': 'socks5://127.0.0.1:9050',
|
'http': 'socks5://127.0.0.1:9050',
|
||||||
|
|
Loading…
Reference in New Issue