Home / Function/ get_connection_with_tls_context() — requests Function Reference

get_connection_with_tls_context() — requests Function Reference

Architecture documentation for the get_connection_with_tls_context() function in adapters.py from the requests codebase.

Function python CoreAPI SessionLifecycle calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  b63a634d_66d8_29cd_773b_da0e87ccd411["get_connection_with_tls_context()"]
  5fdf5d52_8295_768a_e20f_c6cefb721b91["HTTPAdapter"]
  b63a634d_66d8_29cd_773b_da0e87ccd411 -->|defined in| 5fdf5d52_8295_768a_e20f_c6cefb721b91
  66fc1563_b020_b369_a505_bc9abe7cf66d["send()"]
  66fc1563_b020_b369_a505_bc9abe7cf66d -->|calls| b63a634d_66d8_29cd_773b_da0e87ccd411
  9e25d4cd_58ba_4762_6222_2cc3ce1b67bb["build_connection_pool_key_attributes()"]
  b63a634d_66d8_29cd_773b_da0e87ccd411 -->|calls| 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb
  4e2f0f8e_636e_37d3_f714_243f18338137["proxy_manager_for()"]
  b63a634d_66d8_29cd_773b_da0e87ccd411 -->|calls| 4e2f0f8e_636e_37d3_f714_243f18338137
  60571fa2_2c29_a402_f268_a16ac679a1da["select_proxy()"]
  b63a634d_66d8_29cd_773b_da0e87ccd411 -->|calls| 60571fa2_2c29_a402_f268_a16ac679a1da
  9e0e1cd7_43e2_1740_9ce8_96012bdf42f7["prepend_scheme_if_needed()"]
  b63a634d_66d8_29cd_773b_da0e87ccd411 -->|calls| 9e0e1cd7_43e2_1740_9ce8_96012bdf42f7
  style b63a634d_66d8_29cd_773b_da0e87ccd411 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/adapters.py lines 425–472

    def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
        """Returns a urllib3 connection for the given request and TLS settings.
        This should not be called from user code, and is only exposed for use
        when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param request:
            The :class:`PreparedRequest <PreparedRequest>` object to be sent
            over the connection.
        :param verify:
            Either a boolean, in which case it controls whether we verify the
            server's TLS certificate, or a string, in which case it must be a
            path to a CA bundle to use.
        :param proxies:
            (optional) The proxies dictionary to apply to the request.
        :param cert:
            (optional) Any user-provided SSL certificate to be used for client
            authentication (a.k.a., mTLS).
        :rtype:
            urllib3.ConnectionPool
        """
        proxy = select_proxy(request.url, proxies)
        try:
            host_params, pool_kwargs = self.build_connection_pool_key_attributes(
                request,
                verify,
                cert,
            )
        except ValueError as e:
            raise InvalidURL(e, request=request)
        if proxy:
            proxy = prepend_scheme_if_needed(proxy, "http")
            proxy_url = parse_url(proxy)
            if not proxy_url.host:
                raise InvalidProxyURL(
                    "Please check proxy URL. It is malformed "
                    "and could be missing the host."
                )
            proxy_manager = self.proxy_manager_for(proxy)
            conn = proxy_manager.connection_from_host(
                **host_params, pool_kwargs=pool_kwargs
            )
        else:
            # Only scheme should be lower case
            conn = self.poolmanager.connection_from_host(
                **host_params, pool_kwargs=pool_kwargs
            )

        return conn

Domain

Subdomains

Called By

Frequently Asked Questions

What does get_connection_with_tls_context() do?
get_connection_with_tls_context() is a function in the requests codebase, defined in src/requests/adapters.py.
Where is get_connection_with_tls_context() defined?
get_connection_with_tls_context() is defined in src/requests/adapters.py at line 425.
What does get_connection_with_tls_context() call?
get_connection_with_tls_context() calls 4 function(s): build_connection_pool_key_attributes, prepend_scheme_if_needed, proxy_manager_for, select_proxy.
What calls get_connection_with_tls_context()?
get_connection_with_tls_context() is called by 1 function(s): send.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free