当前位置: 首页>>代码示例>>Python>>正文


Python urllib3.HTTPSConnectionPool方法代码示例

本文整理汇总了Python中urllib3.HTTPSConnectionPool方法的典型用法代码示例。如果您正苦于以下问题:Python urllib3.HTTPSConnectionPool方法的具体用法?Python urllib3.HTTPSConnectionPool怎么用?Python urllib3.HTTPSConnectionPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3的用法示例。


在下文中一共展示了urllib3.HTTPSConnectionPool方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def __init__(self, address='http://localhost:4161/', **kwargs):
        """Use :meth:`LookupdClient.from_url` instead.

        .. deprecated:: 1.0.0
        """
        self.address = self.base_url = address

        url = urllib3.util.parse_url(address)
        if url.host:
            kwargs.setdefault('host', url.host)

        if url.port:
            kwargs.setdefault('port', url.port)

        if url.scheme == 'https':
            kwargs.setdefault('connection_class', urllib3.HTTPSConnectionPool)

        return super(Lookupd, self).__init__(**kwargs) 
开发者ID:wtolson,项目名称:gnsq,代码行数:20,代码来源:lookupd.py

示例2: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		
		# Additionally to adding our variant of the usual HTTP and HTTPS
		# pool classes, also add these for some variants of the default schemes
		# that are limited to some specific address family only
		self.pool_classes_by_scheme = {}
		for scheme, ConnectionPool in (("http", HTTPConnectionPool), ("https", HTTPSConnectionPool)):
			self.pool_classes_by_scheme[scheme] = ConnectionPool
			for name in AF2NAME.values():
				self.pool_classes_by_scheme["{0}+{1}".format(scheme, name)] = ConnectionPool
				self.key_fn_by_scheme["{0}+{1}".format(scheme, name)] = self.key_fn_by_scheme[scheme]

	# These next two are only required to ensure that our custom `scheme` values
	# will be passed down to the `*ConnectionPool`s and finally to the actual
	# `*Connection`s as parameter 
开发者ID:ipfs-shipyard,项目名称:py-ipfs-http-client,代码行数:18,代码来源:requests_wrapper.py

示例3: __https_pool

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def __https_pool(self):
        """
        Create HTTP connection pool
        :raise HttpsRequestError
        :return: urllib3.HTTPConnectionPool
        """

        try:
            pool = HTTPSConnectionPool(
                    host=self.__cfg.host,
                    port=self.__cfg.port,
                    maxsize=self.__cfg.threads,
                    timeout=Timeout(self.__cfg.timeout, read=self.__cfg.timeout),
                    block=True)
            if self._HTTP_DBG_LEVEL <= self.__debug.level:
                self.__debug.debug_connection_pool('https_pool_start', pool)

            return pool
        except Exception as error:
            raise HttpsRequestError(str(error)) 
开发者ID:stanislav-web,项目名称:OpenDoor,代码行数:22,代码来源:https.py

示例4: from_url

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def from_url(cls, url, **kwargs):
        """Create a client from a url."""
        url = urllib3.util.parse_url(url)
        if url.host:
            kwargs.setdefault('host', url.host)

        if url.port:
            kwargs.setdefault('port', url.port)

        if url.scheme == 'https':
            kwargs.setdefault('connection_class', urllib3.HTTPSConnectionPool)

        return cls(**kwargs) 
开发者ID:wtolson,项目名称:gnsq,代码行数:15,代码来源:httpclient.py

示例5: askGeorg

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def askGeorg(connectString):
    connectString = connectString
    o = urlparse(connectString)
    try:
        httpPort = o.port
    except:
        if o.scheme == "https":
            httpPort = 443
        else:
            httpPort = 80
    httpScheme = o.scheme
    httpHost = o.netloc.split(":")[0]
    httpPath = o.path
    if o.scheme == "http":
        httpScheme = urllib3.HTTPConnectionPool
    else:
        httpScheme = urllib3.HTTPSConnectionPool

    conn = httpScheme(host=httpHost, port=httpPort)
    response = conn.request("GET", httpPath)
    if response.status == 200:
        if BASICCHECKSTRING == response.data.strip():
            log.info(BASICCHECKSTRING)
            return True
    conn.close()
    return False 
开发者ID:artikrh,项目名称:HackTheBox,代码行数:28,代码来源:reGeorgSocksProxy.py

示例6: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def __init__(self, host='localhost', port=9200, http_auth=None,
            use_ssl=False, verify_certs=False, ca_certs=None, client_cert=None,
            maxsize=10, **kwargs):

        super(Urllib3HttpConnection, self).__init__(host=host, port=port, **kwargs)
        self.headers = {}
        if http_auth is not None:
            if isinstance(http_auth, (tuple, list)):
                http_auth = ':'.join(http_auth)
            self.headers = urllib3.make_headers(basic_auth=http_auth)

        pool_class = urllib3.HTTPConnectionPool
        kw = {}
        if use_ssl:
            pool_class = urllib3.HTTPSConnectionPool

            if verify_certs:
                kw['cert_reqs'] = 'CERT_REQUIRED'
                kw['ca_certs'] = ca_certs
                kw['cert_file'] = client_cert
            elif ca_certs:
                raise ImproperlyConfigured("You cannot pass CA certificates when verify SSL is off.")
            else:
                warnings.warn(
                    'Connecting to %s using SSL with verify_certs=False is insecure.' % host)

        self.pool = pool_class(host, port=port, timeout=self.timeout, maxsize=maxsize, **kw) 
开发者ID:hvandenb,项目名称:splunk-elasticsearch,代码行数:29,代码来源:http_urllib3.py

示例7: test_bad_urllib3_kwarg_usage

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def test_bad_urllib3_kwarg_usage(self):
        python_node = self.get_ast_node(
            """
            import urllib3
            import ssl
            from ssl import CERT_NONE

            urllib3.PoolManager(cert_reqs="CERT_NONE")
            urllib3.ProxyManager(cert_reqs="CERT_NONE")
            urllib3.HTTPSConnectionPool(cert_reqs="NONE")
            urllib3.connection_from_url(cert_reqs=ssl.CERT_NONE)
            urllib3.proxy_from_url(cert_reqs=CERT_NONE)
            """
        )

        linter = dlint.linters.BadUrllib3KwargUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=7,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=8,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=9,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=10,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
        ]

        assert result == expected 
开发者ID:duo-labs,项目名称:dlint,代码行数:50,代码来源:test_bad_urllib3_kwarg_use.py

示例8: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import HTTPSConnectionPool [as 别名]
def __init__(self, host='localhost', port=9200, http_auth=None,
            use_ssl=False, verify_certs=True, ca_certs=None, client_cert=None,
            client_key=None, ssl_version=None, ssl_assert_hostname=None,
            ssl_assert_fingerprint=None, maxsize=10, headers=None, **kwargs):

        super(Urllib3HttpConnection, self).__init__(host=host, port=port, use_ssl=use_ssl, **kwargs)
        self.headers = urllib3.make_headers(keep_alive=True)
        if http_auth is not None:
            if isinstance(http_auth, (tuple, list)):
                http_auth = ':'.join(http_auth)
            self.headers.update(urllib3.make_headers(basic_auth=http_auth))

        # update headers in lowercase to allow overriding of auth headers
        if headers:
            for k in headers:
                self.headers[k.lower()] = headers[k]

        self.headers.setdefault('content-type', 'application/json')
        ca_certs = CA_CERTS if ca_certs is None else ca_certs
        pool_class = urllib3.HTTPConnectionPool
        kw = {}
        if use_ssl:
            pool_class = urllib3.HTTPSConnectionPool
            kw.update({
                'ssl_version': ssl_version,
                'assert_hostname': ssl_assert_hostname,
                'assert_fingerprint': ssl_assert_fingerprint,
            })

            if verify_certs:
                if not ca_certs:
                    raise ImproperlyConfigured("Root certificates are missing for certificate "
                        "validation. Either pass them in using the ca_certs parameter or "
                        "install certifi to use it automatically.")

                kw.update({
                    'cert_reqs': 'CERT_REQUIRED',
                    'ca_certs': ca_certs,
                    'cert_file': client_cert,
                    'key_file': client_key,
                })
            else:
                warnings.warn(
                    'Connecting to %s using SSL with verify_certs=False is insecure.' % host)

        self.pool = pool_class(host, port=port, timeout=self.timeout, maxsize=maxsize, **kw) 
开发者ID:iagcl,项目名称:watchmen,代码行数:48,代码来源:http_urllib3.py


注:本文中的urllib3.HTTPSConnectionPool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。