common.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:incubator-milagro-mfa-server 作者: apache 项目源码 文件源码
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(",")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号