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


Python PoolManager.connection_from_host方法代码示例

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


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

示例1: test_pools_keyed_with_from_host

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_pools_keyed_with_from_host(self):
        """Assert pools are still keyed correctly with connection_from_host."""
        ssl_kw = {
            'key_file': '/root/totally_legit.key',
            'cert_file': '/root/totally_legit.crt',
            'cert_reqs': 'CERT_REQUIRED',
            'ca_certs': '/root/path_to_pem',
            'ssl_version': 'SSLv23_METHOD',
        }
        p = PoolManager(5, **ssl_kw)
        conns = []
        conns.append(
            p.connection_from_host('example.com', 443, scheme='https')
        )

        for k in ssl_kw:
            p.connection_pool_kw[k] = 'newval'
            conns.append(
                p.connection_from_host('example.com', 443, scheme='https')
            )

        assert all(
            x is not y
            for i, x in enumerate(conns)
            for j, y in enumerate(conns)
            if i != j
        )
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:29,代码来源:test_poolmanager.py

示例2: test_http_connection_from_host_case_insensitive

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_http_connection_from_host_case_insensitive(self):
        """Assert scheme case is ignored when getting the https key class."""
        p = PoolManager()
        pool = p.connection_from_host('example.com', scheme='http')
        other_pool = p.connection_from_host('EXAMPLE.COM', scheme='HTTP')

        assert 1 == len(p.pools)
        assert pool is other_pool
        assert all(isinstance(key, PoolKey) for key in p.pools.keys())
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:11,代码来源:test_poolmanager.py

示例3: test_http_connection_from_host_case_insensitive

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_http_connection_from_host_case_insensitive(self):
        """Assert scheme case is ignored when getting the https key class."""
        p = PoolManager()
        self.addCleanup(p.clear)
        pool = p.connection_from_host('example.com', scheme='http')
        other_pool = p.connection_from_host('EXAMPLE.COM', scheme='HTTP')

        self.assertEqual(1, len(p.pools))
        self.assertTrue(pool is other_pool)
        self.assertTrue(all(isinstance(key, PoolKey) for key in p.pools.keys()))
开发者ID:cloudera,项目名称:hue,代码行数:12,代码来源:test_poolmanager.py

示例4: test_pool_kwargs_socket_options

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_pool_kwargs_socket_options(self):
        """Assert passing socket options works with connection_from_host"""
        p = PoolManager(socket_options=[])
        override_opts = [
            (socket.SOL_SOCKET, socket.SO_REUSEADDR, 1),
            (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
        ]
        pool_kwargs = {'socket_options': override_opts}

        default_pool = p.connection_from_host('example.com', scheme='http')
        override_pool = p.connection_from_host(
            'example.com', scheme='http', pool_kwargs=pool_kwargs
        )

        assert default_pool.conn_kw['socket_options'] == []
        assert override_pool.conn_kw['socket_options'] == override_opts
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:18,代码来源:test_poolmanager.py

示例5: test_override_pool_kwargs_host

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_override_pool_kwargs_host(self):
        """Assert overriding pool kwargs works with connection_from_host"""
        p = PoolManager(strict=True)
        pool_kwargs = {'strict': False, 'retries': 100, 'block': True}

        default_pool = p.connection_from_host('example.com', scheme='http')
        override_pool = p.connection_from_host('example.com', scheme='http',
                                               pool_kwargs=pool_kwargs)

        assert default_pool.strict
        assert retry.Retry.DEFAULT == default_pool.retries
        assert not default_pool.block

        assert not override_pool.strict
        assert 100 == override_pool.retries
        assert override_pool.block
开发者ID:NickMinnellaCS96,项目名称:urllib3,代码行数:18,代码来源:test_poolmanager.py

示例6: test_override_pool_kwargs_host

# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import connection_from_host [as 别名]
    def test_override_pool_kwargs_host(self):
        """Assert overriding pool kwargs works with connection_from_host"""
        p = PoolManager(strict=True)
        pool_kwargs = {'strict': False, 'retries': 100, 'block': True}

        default_pool = p.connection_from_host('example.com', scheme='http')
        override_pool = p.connection_from_host('example.com', scheme='http',
                                               pool_kwargs=pool_kwargs)

        self.assertTrue(default_pool.strict)
        self.assertEqual(retry.Retry.DEFAULT, default_pool.retries)
        self.assertFalse(default_pool.block)

        self.assertFalse(override_pool.strict)
        self.assertEqual(100, override_pool.retries)
        self.assertTrue(override_pool.block)
开发者ID:cloudera,项目名称:hue,代码行数:18,代码来源:test_poolmanager.py


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