當前位置: 首頁>>代碼示例>>Python>>正文


Python urllib2.ProxyDigestAuthHandler方法代碼示例

本文整理匯總了Python中urllib2.ProxyDigestAuthHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python urllib2.ProxyDigestAuthHandler方法的具體用法?Python urllib2.ProxyDigestAuthHandler怎麽用?Python urllib2.ProxyDigestAuthHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib2的用法示例。


在下文中一共展示了urllib2.ProxyDigestAuthHandler方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import ProxyDigestAuthHandler [as 別名]
def setUp(self):
        super(ProxyAuthTests, self).setUp()
        # Ignore proxy bypass settings in the environment.
        def restore_environ(old_environ):
            os.environ.clear()
            os.environ.update(old_environ)
        self.addCleanup(restore_environ, os.environ.copy())
        os.environ['NO_PROXY'] = ''
        os.environ['no_proxy'] = ''

        self.digest_auth_handler = DigestAuthHandler()
        self.digest_auth_handler.set_users({self.USER: self.PASSWD})
        self.digest_auth_handler.set_realm(self.REALM)
        # With Digest Authentication
        def create_fake_proxy_handler(*args, **kwargs):
            return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs)

        self.server = LoopbackHttpServerThread(create_fake_proxy_handler)
        self.server.start()
        self.server.ready.wait()
        self.addCleanup(self.server.stop)
        proxy_url = "http://127.0.0.1:%d" % self.server.port
        handler = urllib2.ProxyHandler({"http" : proxy_url})
        self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler()
        self.opener = urllib2.build_opener(handler, self.proxy_digest_handler) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:test_urllib2_localnet.py

示例2: setUp

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import ProxyDigestAuthHandler [as 別名]
def setUp(self):
        super(ProxyAuthTests, self).setUp()
        self.digest_auth_handler = DigestAuthHandler()
        self.digest_auth_handler.set_users({self.USER: self.PASSWD})
        self.digest_auth_handler.set_realm(self.REALM)
        # With Digest Authentication
        def create_fake_proxy_handler(*args, **kwargs):
            return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs)

        self.server = LoopbackHttpServerThread(create_fake_proxy_handler)
        self.server.start()
        self.server.ready.wait()
        proxy_url = "http://127.0.0.1:%d" % self.server.port
        handler = urllib2.ProxyHandler({"http" : proxy_url})
        self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler()
        self.opener = urllib2.build_opener(handler, self.proxy_digest_handler) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:18,代碼來源:test_urllib2_localnet.py

示例3: setUp

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import ProxyDigestAuthHandler [as 別名]
def setUp(self):
        super(ProxyAuthTests, self).setUp()
        self.digest_auth_handler = DigestAuthHandler()
        self.digest_auth_handler.set_users({self.USER: self.PASSWD})
        self.digest_auth_handler.set_realm(self.REALM)
        def create_fake_proxy_handler(*args, **kwargs):
            return FakeProxyHandler(self.digest_auth_handler, *args, **kwargs)

        self.server = LoopbackHttpServerThread(create_fake_proxy_handler)
        self.server.start()
        self.server.ready.wait()
        proxy_url = "http://127.0.0.1:%d" % self.server.port
        handler = urllib2.ProxyHandler({"http" : proxy_url})
        self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler()
        self.opener = urllib2.build_opener(handler, self.proxy_digest_handler) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:17,代碼來源:test_urllib2_localnet.py

示例4: setUp

# 需要導入模塊: import urllib2 [as 別名]
# 或者: from urllib2 import ProxyDigestAuthHandler [as 別名]
def setUp(self):
        FakeProxyHandler.digest_auth_handler.set_users({
            self.USER : self.PASSWD
            })
        FakeProxyHandler.digest_auth_handler.set_realm(self.REALM)

        self.server = LoopbackHttpServerThread(self.PORT, FakeProxyHandler)
        self.server.start()
        self.server.ready.wait()

        handler = urllib2.ProxyHandler({"http" : self.PROXY_URL})
        self._digest_auth_handler = urllib2.ProxyDigestAuthHandler()
        self.opener = urllib2.build_opener(handler, self._digest_auth_handler) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:15,代碼來源:test_urllib2_localnet.py


注:本文中的urllib2.ProxyDigestAuthHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。