Exemplo n.º 1
0
def get_requests_session():
    requests_session = requests.Session()
    for cls in plugin_manager.get_transport_plugins():
        transport_plugin = cls()
        requests_session.mount(prefix=transport_plugin.prefix,
                               adapter=transport_plugin.get_adapter())
    return requests_session
Exemplo n.º 2
0
def get_requests_session():
    requests_session = requests.Session()
    for cls in plugin_manager.get_transport_plugins():
        transport_plugin = cls()
        requests_session.mount(prefix=transport_plugin.prefix,
                               adapter=transport_plugin.get_adapter())
    return requests_session
Exemplo n.º 3
0
def get_requests_session(ssl_version):
    requests_session = requests.Session()
    requests_session.mount("https://", HTTPieHTTPAdapter(ssl_version=ssl_version))
    for cls in plugin_manager.get_transport_plugins():
        transport_plugin = cls()
        requests_session.mount(prefix=transport_plugin.prefix, adapter=transport_plugin.get_adapter())
    return requests_session
Exemplo n.º 4
0
def build_requests_session(
    verify: bool,
    ssl_version: str = None,
    ciphers: str = None,
) -> requests.Session:
    requests_session = requests.Session()

    # Install our adapter.
    https_adapter = HTTPieHTTPSAdapter(
        ciphers=ciphers,
        verify=verify,
        ssl_version=(AVAILABLE_SSL_VERSION_ARG_MAPPING[ssl_version]
                     if ssl_version else None),
    )
    requests_session.mount('https://', https_adapter)

    # Install adapters from plugins.
    for plugin_cls in plugin_manager.get_transport_plugins():
        transport_plugin = plugin_cls()
        requests_session.mount(
            prefix=transport_plugin.prefix,
            adapter=transport_plugin.get_adapter(),
        )

    return requests_session
Exemplo n.º 5
0
def get_requests_session(ssl_version):
    requests_session = requests.Session()
    requests_session.mount('https://',
                           HTTPieHTTPAdapter(ssl_version=ssl_version))
    for cls in plugin_manager.get_transport_plugins():
        transport_plugin = cls()
        requests_session.mount(prefix=transport_plugin.prefix,
                               adapter=transport_plugin.get_adapter())
    return requests_session
Exemplo n.º 6
0
def get_requests_session(ssl_version, compress):
    requests_session = requests.Session()
    requests_session.mount('https://',
                           HTTPieHTTPAdapter(ssl_version=ssl_version))
    if compress:
        adapter = ContentCompressionHttpAdapter(compress)
        for prefix in ['http://', 'https://']:
            requests_session.mount(prefix, adapter)
    for cls in plugin_manager.get_transport_plugins():
        transport_plugin = cls()
        requests_session.mount(prefix=transport_plugin.prefix,
                               adapter=transport_plugin.get_adapter())
    return requests_session
Exemplo n.º 7
0
def build_requests_session(ssl_version: str = None, ) -> requests.Session:
    requests_session = requests.Session()

    # Install our adapter.
    requests_session.mount(
        'https://',
        HTTPieHTTPSAdapter(ssl_version=(
            SSL_VERSION_ARG_MAPPING[ssl_version] if ssl_version else None)))

    # Install adapters from plugins.
    for plugin_cls in plugin_manager.get_transport_plugins():
        transport_plugin = plugin_cls()
        requests_session.mount(
            prefix=transport_plugin.prefix,
            adapter=transport_plugin.get_adapter(),
        )

    return requests_session
Exemplo n.º 8
0
def build_requests_session(
    compress_arg: int,
    ssl_version: str = None,
) -> requests.Session:
    requests_session = requests.Session()

    # Install our adapter.
    adapter = HTTPieHTTPAdapter(
        ssl_version=SSL_VERSION_ARG_MAPPING[ssl_version] if ssl_version else None,
        compression_enabled=compress_arg > 0,
        compress_always=compress_arg > 1,
    )
    requests_session.mount('http://', adapter)
    requests_session.mount('https://', adapter)

    # Install adapters from plugins.
    for plugin_cls in plugin_manager.get_transport_plugins():
        transport_plugin = plugin_cls()
        requests_session.mount(
            prefix=transport_plugin.prefix,
            adapter=transport_plugin.get_adapter(),
        )

    return requests_session