Skip to content

Commit

Permalink
Allow HTTP-exclusive proxies for all requests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benbusby committed Dec 12, 2022
1 parent 8fbbdf2 commit 7a852aa
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions app/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,13 @@ def __init__(self, normal_ua, root_path, config: Config):
proxy_pass = os.environ.get('WHOOGLE_PROXY_PASS', '')
auth_str = ''
if proxy_user:
auth_str = proxy_user + ':' + proxy_pass
auth_str = f'{proxy_user}:{proxy_pass}@'

proxy_str = f'{proxy_type}://{auth_str}{proxy_path}'
self.proxies = {
'https': proxy_type + '://' +
((auth_str + '@') if auth_str else '') + proxy_path,
'https': proxy_str,
'http': proxy_str
}

# 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']
else:
self.proxies = {
'http': 'socks5://127.0.0.1:9050',
Expand Down

0 comments on commit 7a852aa

Please sign in to comment.