Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.urllib3.poolmanager Namespace Reference

Data Structures

class  PoolManager
 
class  ProxyManager
 

Functions

 _default_key_normalizer (key_class, request_context)
 
 proxy_from_url (url, **kw)
 

Variables

 log = logging.getLogger(__name__)
 
tuple SSL_KEYWORDS
 
tuple _key_fields
 
 PoolKey = collections.namedtuple("PoolKey", _key_fields)
 
tuple _proxy_config_fields = ("ssl_context", "use_forwarding_for_https")
 
 ProxyConfig = collections.namedtuple("ProxyConfig", _proxy_config_fields)
 
dict key_fn_by_scheme
 
dict pool_classes_by_scheme = {"http": HTTPConnectionPool, "https": HTTPSConnectionPool}
 

Function Documentation

◆ _default_key_normalizer()

_default_key_normalizer (   key_class,
  request_context 
)
protected
Create a pool key out of a request context dictionary.

According to RFC 3986, both the scheme and host are case-insensitive.
Therefore, this function normalizes both before constructing the pool
key for an HTTPS request. If you wish to change this behaviour, provide
alternate callables to ``key_fn_by_scheme``.

:param key_class:
    The class to use when constructing the key. This should be a namedtuple
    with the ``scheme`` and ``host`` keys at a minimum.
:type  key_class: namedtuple
:param request_context:
    A dictionary-like object that contain the context for a request.
:type  request_context: dict

:return: A namedtuple that can be used as a connection pool key.
:rtype:  PoolKey

Definition at line 79 of file poolmanager.py.

79def _default_key_normalizer(key_class, request_context):
80 """
81 Create a pool key out of a request context dictionary.
82
83 According to RFC 3986, both the scheme and host are case-insensitive.
84 Therefore, this function normalizes both before constructing the pool
85 key for an HTTPS request. If you wish to change this behaviour, provide
86 alternate callables to ``key_fn_by_scheme``.
87
88 :param key_class:
89 The class to use when constructing the key. This should be a namedtuple
90 with the ``scheme`` and ``host`` keys at a minimum.
91 :type key_class: namedtuple
92 :param request_context:
93 A dictionary-like object that contain the context for a request.
94 :type request_context: dict
95
96 :return: A namedtuple that can be used as a connection pool key.
97 :rtype: PoolKey
98 """
99 # Since we mutate the dictionary, make a copy first
100 context = request_context.copy()
101 context["scheme"] = context["scheme"].lower()
102 context["host"] = context["host"].lower()
103
104 # These are both dictionaries and need to be transformed into frozensets
105 for key in ("headers", "_proxy_headers", "_socks_options"):
106 if key in context and context[key] is not None:
107 context[key] = frozenset(context[key].items())
108
109 # The socket_options key may be a list and needs to be transformed into a
110 # tuple.
111 socket_opts = context.get("socket_options")
112 if socket_opts is not None:
113 context["socket_options"] = tuple(socket_opts)
114
115 # Map the kwargs to the names in the namedtuple - this is necessary since
116 # namedtuples can't have fields starting with '_'.
117 for key in list(context.keys()):
118 context["key_" + key] = context.pop(key)
119
120 # Default to ``None`` for keys missing from the context
121 for field in key_class._fields:
122 if field not in context:
123 context[field] = None
124
125 return key_class(**context)
126
127
128#: A dictionary that maps a scheme to a callable that creates a pool key.
129#: This can be used to alter the way pool keys are constructed, if desired.
130#: Each PoolManager makes a copy of this dictionary so they can be configured
131#: globally here, or individually on the instance.
for i

References i.

◆ proxy_from_url()

proxy_from_url (   url,
**  kw 
)

Definition at line 536 of file poolmanager.py.

536def proxy_from_url(url, **kw):
537 return ProxyManager(proxy_url=url, **kw)

Variable Documentation

◆ _key_fields

tuple _key_fields
protected
Initial value:
1= (
2 "key_scheme", # str
3 "key_host", # str
4 "key_port", # int
5 "key_timeout", # int or float or Timeout
6 "key_retries", # int or Retry
7 "key_strict", # bool
8 "key_block", # bool
9 "key_source_address", # str
10 "key_key_file", # str
11 "key_key_password", # str
12 "key_cert_file", # str
13 "key_cert_reqs", # str
14 "key_ca_certs", # str
15 "key_ssl_version", # str
16 "key_ca_cert_dir", # str
17 "key_ssl_context", # instance of ssl.SSLContext or urllib3.util.ssl_.SSLContext
18 "key_maxsize", # int
19 "key_headers", # dict
20 "key__proxy", # parsed proxy url
21 "key__proxy_headers", # dict
22 "key__proxy_config", # class
23 "key_socket_options", # list of (level (int), optname (int), value (int or str)) tuples
24 "key__socks_options", # dict
25 "key_assert_hostname", # bool or string
26 "key_assert_fingerprint", # str
27 "key_server_hostname", # str
28)

Definition at line 42 of file poolmanager.py.

◆ _proxy_config_fields

tuple _proxy_config_fields = ("ssl_context", "use_forwarding_for_https")
protected

Definition at line 75 of file poolmanager.py.

◆ key_fn_by_scheme

dict key_fn_by_scheme
Initial value:
1= {
2 "http": functools.partial(_default_key_normalizer, PoolKey),
3 "https": functools.partial(_default_key_normalizer, PoolKey),
4}

Definition at line 132 of file poolmanager.py.

◆ log

log = logging.getLogger(__name__)

Definition at line 26 of file poolmanager.py.

◆ pool_classes_by_scheme

dict pool_classes_by_scheme = {"http": HTTPConnectionPool, "https": HTTPSConnectionPool}

Definition at line 137 of file poolmanager.py.

◆ PoolKey

PoolKey = collections.namedtuple("PoolKey", _key_fields)

Definition at line 73 of file poolmanager.py.

◆ ProxyConfig

ProxyConfig = collections.namedtuple("ProxyConfig", _proxy_config_fields)

Definition at line 76 of file poolmanager.py.

◆ SSL_KEYWORDS

tuple SSL_KEYWORDS
Initial value:
1= (
2 "key_file",
3 "cert_file",
4 "cert_reqs",
5 "ca_certs",
6 "ssl_version",
7 "ca_cert_dir",
8 "ssl_context",
9 "key_password",
10 "server_hostname",
11)

Definition at line 28 of file poolmanager.py.