def _get_proxy_config(self):
"""
Determine if self._url should be passed through a proxy. If so, return
the appropriate proxy_server and proxy_port. Assumes https_proxy is used
when ssl_enabled=True.
"""
proxy_server = None
proxy_port = None
ssl_enabled = self._ssl_enabled
if ssl_enabled:
proxy = os.environ.get("https_proxy")
else:
proxy = os.environ.get("http_proxy")
no_proxy = os.environ.get("no_proxy")
no_proxy_url = no_proxy and self._server in no_proxy
if proxy and not no_proxy_url:
p = urlparse(proxy)
proxy_server = p.hostname
proxy_port = p.port
return proxy_server, proxy_port
评论列表
文章目录