Skip to content

Commit

Permalink
Update utils.py to use urllib3.ProxyManager
Browse files Browse the repository at this point in the history
When using ProxyManager instead of Poolmanager the proxy settings will be used when provided in proxy_url. Proxy_url can be retrieved from the environment variables 
proxy_url = os.environ.get('http_proxy') or os.environ.get('https_proxy')
  • Loading branch information
SecPascal authored and mjpieters committed Dec 7, 2023
1 parent e22d192 commit 20bbeb6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aocd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ class HttpClient:
# aocd users should not need to use this class directly.

def __init__(self):
self.pool_manager = urllib3.PoolManager(headers={"User-Agent": USER_AGENT})

proxy_url = os.environ.get('http_proxy') or os.environ.get('https_proxy')
if proxy_url:
self.pool_manager = urllib3.ProxyManager(proxy_url, headers={"User-Agent": USER_AGENT})
else:
self.pool_manager = urllib3.PoolManager(headers={"User-Agent": USER_AGENT})
self.req_count = {"GET": 0, "POST": 0}
self._max_t = 3.0
self._cooloff = 0.16
Expand Down

0 comments on commit 20bbeb6

Please sign in to comment.