本文整理汇总了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.