build_connection_pool_key_attributes() — requests Function Reference
Architecture documentation for the build_connection_pool_key_attributes() function in adapters.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb["build_connection_pool_key_attributes()"] 5fdf5d52_8295_768a_e20f_c6cefb721b91["HTTPAdapter"] 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb -->|defined in| 5fdf5d52_8295_768a_e20f_c6cefb721b91 b63a634d_66d8_29cd_773b_da0e87ccd411["get_connection_with_tls_context()"] b63a634d_66d8_29cd_773b_da0e87ccd411 -->|calls| 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb 989cb094_bf00_56e8_7848_2b8a03832cbc["_urllib3_request_context()"] 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb -->|calls| 989cb094_bf00_56e8_7848_2b8a03832cbc style 9e25d4cd_58ba_4762_6222_2cc3ce1b67bb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/adapters.py lines 375–423
def build_connection_pool_key_attributes(self, request, verify, cert=None):
"""Build the PoolKey attributes used by urllib3 to return a connection.
This looks at the PreparedRequest, the user-specified verify value,
and the value of the cert parameter to determine what PoolKey values
to use to select a connection from a given urllib3 Connection Pool.
The SSL related pool key arguments are not consistently set. As of
this writing, use the following to determine what keys may be in that
dictionary:
* If ``verify`` is ``True``, ``"ssl_context"`` will be set and will be the
default Requests SSL Context
* If ``verify`` is ``False``, ``"ssl_context"`` will not be set but
``"cert_reqs"`` will be set
* If ``verify`` is a string, (i.e., it is a user-specified trust bundle)
``"ca_certs"`` will be set if the string is not a directory recognized
by :py:func:`os.path.isdir`, otherwise ``"ca_cert_dir"`` will be
set.
* If ``"cert"`` is specified, ``"cert_file"`` will always be set. If
``"cert"`` is a tuple with a second item, ``"key_file"`` will also
be present
To override these settings, one may subclass this class, call this
method and use the above logic to change parameters as desired. For
example, if one wishes to use a custom :py:class:`ssl.SSLContext` one
must both set ``"ssl_context"`` and based on what else they require,
alter the other keys to ensure the desired behaviour.
:param request:
The PreparedReqest being sent over the connection.
:type request:
:class:`~requests.models.PreparedRequest`
: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 cert:
(optional) Any user-provided SSL certificate for client
authentication (a.k.a., mTLS). This may be a string (i.e., just
the path to a file which holds both certificate and key) or a
tuple of length 2 with the certificate file path and key file
path.
:returns:
A tuple of two dictionaries. The first is the "host parameters"
portion of the Pool Key including scheme, hostname, and port. The
second is a dictionary of SSLContext related parameters.
"""
return _urllib3_request_context(request, verify, cert, self.poolmanager)
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does build_connection_pool_key_attributes() do?
build_connection_pool_key_attributes() is a function in the requests codebase, defined in src/requests/adapters.py.
Where is build_connection_pool_key_attributes() defined?
build_connection_pool_key_attributes() is defined in src/requests/adapters.py at line 375.
What does build_connection_pool_key_attributes() call?
build_connection_pool_key_attributes() calls 1 function(s): _urllib3_request_context.
What calls build_connection_pool_key_attributes()?
build_connection_pool_key_attributes() is called by 1 function(s): get_connection_with_tls_context.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free