def detectProxy():
# Detect proxy settings for http and https from the environment
# Uses http_proxy and https_proxy environment variables
httpProxy = os.environ.get("HTTP_PROXY", os.environ.get("http_proxy", ""))
httpsProxy = os.environ.get("HTTPS_PROXY", os.environ.get("https_proxy", ""))
noProxy = os.environ.get("NO_PROXY", os.environ.get("no_proxy", ""))
if httpProxy:
u = urlparse(httpProxy)
proxies["http"] = {
"proxy_host": u.hostname or None,
"proxy_port": u.port or None,
"proxy_username": u.username or None,
"proxy_password": u.password or None
}
if httpsProxy:
u = urlparse(httpsProxy)
proxies["https"] = {
"proxy_host": u.hostname or None,
"proxy_port": u.port or None,
"proxy_username": u.username or None,
"proxy_password": u.password or None
}
if httpProxy or httpsProxy:
tornado.httpclient.AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
if noProxy:
proxies["noProxy"] = noProxy.split(",")
评论列表
文章目录