File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 11import certifi
22import json
3+ import os
34import urllib3
45import inspect
56from urllib3 .util .retry import Retry
@@ -70,14 +71,22 @@ def __init__(
7071
7172 # https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html
7273 # https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool
73- self . client = urllib3 . PoolManager (
74+ pool_kwargs = dict (
7475 num_pools = num_pools ,
75- headers = self .headers , # default headers sent with each request.
76+ headers = self .headers ,
7677 ca_certs = certifi .where (),
7778 cert_reqs = "CERT_REQUIRED" ,
78- retries = retry_strategy , # use the customized Retry instance
79+ retries = retry_strategy ,
7980 )
8081
82+ # Check for proxy environment variables (HTTPS_PROXY or HTTP_PROXY)
83+ proxy_url = os .environ .get ("HTTPS_PROXY" ) or os .environ .get ("https_proxy" ) \
84+ or os .environ .get ("HTTP_PROXY" ) or os .environ .get ("http_proxy" )
85+ if proxy_url :
86+ self .client = urllib3 .ProxyManager (proxy_url , ** pool_kwargs )
87+ else :
88+ self .client = urllib3 .PoolManager (** pool_kwargs )
89+
8190 self .timeout = urllib3 .Timeout (connect = connect_timeout , read = read_timeout )
8291
8392 if verbose :
You can’t perform that action at this time.
0 commit comments