本文整理匯總了Python中urllib3.connectionpool.HTTPSConnectionPool方法的典型用法代碼示例。如果您正苦於以下問題:Python connectionpool.HTTPSConnectionPool方法的具體用法?Python connectionpool.HTTPSConnectionPool怎麽用?Python connectionpool.HTTPSConnectionPool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urllib3.connectionpool
的用法示例。
在下文中一共展示了connectionpool.HTTPSConnectionPool方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from urllib3 import connectionpool [as 別名]
# 或者: from urllib3.connectionpool import HTTPSConnectionPool [as 別名]
def __init__(self, host, port, certfile = None, keyfile = None, cacertfile=None, force_ssl = False, *args, **kw):
super(ConnectionPoolManager, self).__init__(*args, **kw)
self.logger.debug("Creating ConnectionPoolManager for %s:%s", host, port)
if certfile or keyfile or force_ssl:
#https://docs.python.org/2/library/ssl.html#ssl.SSLContext
from ssl import SSLContext, PROTOCOL_SSLv23
ssl_context=SSLContext(PROTOCOL_SSLv23)
ssl_context.load_cert_chain(certfile = certfile, keyfile = keyfile)
ssl_context.load_verify_locations(cafile=cacertfile)
#https://docs.python.org/2/library/httplib.html
self.__pool = HTTPSConnectionPool(host, port, maxsize = 16, context = ssl_context)
else:
self.__pool = HTTPConnectionPool(host, port, maxsize = 16)