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 Dec 6, 2023
1 parent 64d216a commit 5e57bcd
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})

Check warning on line 38 in aocd/utils.py

View check run for this annotation

Codecov / codecov/patch

aocd/utils.py#L38

Added line #L38 was not covered by tests
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 5e57bcd

Please sign in to comment.