本文整理匯總了Python中future.backports.http.client.HTTPSConnection方法的典型用法代碼示例。如果您正苦於以下問題:Python client.HTTPSConnection方法的具體用法?Python client.HTTPSConnection怎麽用?Python client.HTTPSConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類future.backports.http.client
的用法示例。
在下文中一共展示了client.HTTPSConnection方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_host_port
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def test_host_port(self):
# Check invalid host_port
# Note that httplib does not accept user:password@ in the host-port.
for hp in ("www.python.org:abc", "user:password@www.python.org"):
self.assertRaises(client.InvalidURL, client.HTTPSConnection, hp)
for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
8000),
("pypi.python.org:443", "pypi.python.org", 443),
("pypi.python.org", "pypi.python.org", 443),
("pypi.python.org:", "pypi.python.org", 443),
("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)):
c = client.HTTPSConnection(hp)
self.assertEqual(h, c.host)
self.assertEqual(p, c.port)
# def test_main(verbose=None):
# support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
# HTTPSTest, SourceAddressTest)
示例2: make_connection
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def make_connection(self, host):
if self._connection and host == self._connection[0]:
return self._connection[1]
if not hasattr(http_client, "HTTPSConnection"):
raise NotImplementedError(
"your version of http.client doesn't support HTTPS")
# create a HTTPS connection object from a host descriptor
# host may be a string, or a (host, x509-dict) tuple
chost, self._extra_headers, x509 = self.get_host_info(host)
self._connection = host, http_client.HTTPSConnection(chost,
None, **(x509 or {}))
return self._connection[1]
##
# Standard server proxy. This class establishes a virtual connection
# to an XML-RPC server.
# <p>
# This class is available as ServerProxy and Server. New code should
# use ServerProxy, to avoid confusion.
#
# @def ServerProxy(uri, **options)
# @param uri The connection point on the server.
# @keyparam transport A transport factory, compatible with the
# standard transport class.
# @keyparam encoding The default encoding used for 8-bit strings
# (default is UTF-8).
# @keyparam verbose Use a true value to enable debugging output.
# (printed to standard output).
# @see Transport
示例3: build_opener
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def build_opener(*handlers):
"""Create an opener object from a list of handlers.
The opener will use several default handlers, including support
for HTTP, FTP and when applicable HTTPS.
If any of the handlers passed as arguments are subclasses of the
default handlers, the default handlers will not be used.
"""
def isclass(obj):
return isinstance(obj, type) or hasattr(obj, "__bases__")
opener = OpenerDirector()
default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
HTTPDefaultErrorHandler, HTTPRedirectHandler,
FTPHandler, FileHandler, HTTPErrorProcessor]
if hasattr(http_client, "HTTPSConnection"):
default_classes.append(HTTPSHandler)
skip = set()
for klass in default_classes:
for check in handlers:
if isclass(check):
if issubclass(check, klass):
skip.add(klass)
elif isinstance(check, klass):
skip.add(klass)
for klass in skip:
default_classes.remove(klass)
for klass in default_classes:
opener.add_handler(klass())
for h in handlers:
if isclass(h):
h = h()
opener.add_handler(h)
return opener
示例4: https_open
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def https_open(self, req):
return self.do_open(http_client.HTTPSConnection, req,
context=self._context, check_hostname=self._check_hostname)
示例5: _https_connection
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def _https_connection(self, host):
return http_client.HTTPSConnection(host,
key_file=self.key_file,
cert_file=self.cert_file)
示例6: testHTTPSConnectionSourceAddress
# 需要導入模塊: from future.backports.http import client [as 別名]
# 或者: from future.backports.http.client import HTTPSConnection [as 別名]
def testHTTPSConnectionSourceAddress(self):
self.conn = client.HTTPSConnection(HOST, self.port,
source_address=('', self.source_port))
# We don't test anything here other the constructor not barfing as
# this code doesn't deal with setting up an active running SSL server
# for an ssl_wrapped connect() to actually return from.