Files
old-saburly-wagtail-web/env/lib/python3.10/site-packages/urllib3/__pycache__/poolmanager.cpython-310.pyc

267 lines
18 KiB
Plaintext
Raw Normal View History

2024-08-27 20:33:44 +02:00
o
<00><><EFBFBD>f<EFBFBD>Y<00>@s<>ddlmZddlZddlZddlZddlZddlmZddlm Z ddl
m Z m Z ddl mZddlmZdd lmZmZmZdd
lmZmZmZmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&ej'rddl(Z(ddl)m*Z*gd<12>Z+e<03>,e-<2D>Z.dZ/dZ0Gdd<16>dej1<6A>Z2d)dd<1D>Z3e<02>4e3e2<65>e<02>4e3e2<65>d<1E>Z5eed<1E>Z6Gdd <20>d e<0E>Z7Gd!d"<22>d"e7<65>Z8d*d'd(<28>Z9dS)+<2B>)<01> annotationsN)<01> TracebackType)<01>urljoin<69>)<02>HTTPHeaderDict<63>RecentlyUsedContainer)<01>RequestMethods)<01> ProxyConfig)<03>HTTPConnectionPool<6F>HTTPSConnectionPool<6F>port_by_scheme)<04>LocationValueError<6F> MaxRetryError<6F>ProxySchemeUnknown<77>URLSchemeUnknown)<01>BaseHTTPResponse)<01>_TYPE_SOCKET_OPTIONS)<01>connection_requires_http_tunnel)<01>Retry)<01>Timeout)<02>Url<72> parse_url)<01>Self)<03> PoolManager<65> ProxyManager<65>proxy_from_url) <0C>key_file<6C> cert_file<6C> cert_reqs<71>ca_certs<74> ca_cert_data<74> ssl_version<6F>ssl_minimum_version<6F>ssl_maximum_version<6F> ca_cert_dir<69> ssl_context<78> key_password<72>server_hostnamei@c@s<>eZdZUdZded<ded<ded<ded<d ed
<d ed <d ed<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<d ed!<d"ed#<d ed$<d%ed&<d'ed(<d ed)<d*ed+<ded,<ded-<ded.<d/S)0<>PoolKeyz<79>
All known keyword arguments that could be provided to the pool manager, its
pools, or the underlying connections.
All custom key schemes should include the fields in this key at a minimum.
<20>str<74>
key_scheme<EFBFBD>key_host<73>
int | None<6E>key_portzTimeout | float | int | None<6E> key_timeoutzRetry | bool | int | None<6E> key_retriesz bool | None<6E> key_blockztuple[str, int] | None<6E>key_source_address<73>
str | None<6E> key_key_file<6C>key_key_password<72> key_cert_file<6C> key_cert_reqs<71> key_ca_certszstr | bytes | None<6E>key_ca_cert_datazint | str | None<6E>key_ssl_versionzssl.TLSVersion | None<6E>key_ssl_minimum_version<6F>key_ssl_maximum_version<6F>key_ca_cert_dir<69>ssl.SSLContext | None<6E>key_ssl_context<78> key_maxsizez!frozenset[tuple[str, str]] | None<6E> key_headers<72>
Url | None<6E>
key__proxy<EFBFBD>key__proxy_headers<72>ProxyConfig | None<6E>key__proxy_configz_TYPE_SOCKET_OPTIONS | None<6E>key_socket_options<6E>key__socks_optionszbool | str | None<6E>key_assert_hostname<6D>key_assert_fingerprint<6E>key_server_hostname<6D> key_blocksizeN)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>__annotations__<5F>rQrQ<00>U/home/amir/Desktop/saburlyweb/env/lib/python3.10/site-packages/urllib3/poolmanager.pyr(8s>
 r(<00> key_class<73> type[PoolKey]<5D>request_context<78>dict[str, typing.Any]<5D>returncCs<>|<01><00>}|d<00><01>|d<|d<00><01>|d<dD]}||vr,||dur,t||<00><03><00>||<q|<02>d<05>}|dur<t|<04>|d<t|<02><07><00>D] }|<02>|<03>|d|<qB|j D]
}||vr[d||<qQ|<02>d<07>durgt
|d<|di|<02><01>S) a<>
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
<20>scheme<6D>host)<03>headers<72>_proxy_headers<72>_socks_optionsN<73>socket_options<6E>key_rKrQ) <0B>copy<70>lower<65> frozenset<65>items<6D>get<65>tuple<6C>list<73>keys<79>pop<6F>_fields<64>_DEFAULT_BLOCKSIZE)rSrU<00>context<78>key<65> socket_opts<74>fieldrQrQrR<00>_default_key_normalizer_s&<02>
 
<02>rn<00><02>http<74>httpscs<>eZdZUdZdZded<dZded<  dHdI<64>fdd<11> ZdJdd<14>ZdKdd<1D>Z dLdMd%d&<26>Z
dNd'd(<28>Z  ) dOdPd-d.<2E>Z dQd0d1<64>Z dRd4d5<64>Z dLdSd7d8<64>ZdTd:d;<3B>ZdUd?d@<40>Z AdVdWdFdG<64>Z<12>ZS)XraV
Allows for arbitrary requests while transparently keeping track of
necessary connection pools for you.
:param num_pools:
Number of connection pools to cache before discarding the least
recently used pool.
:param headers:
Headers to include with all requests, unless other headers are given
explicitly.
:param \**connection_pool_kw:
Additional parameters are used to create fresh
:class:`urllib3.connectionpool.ConnectionPool` instances.
Example:
.. code-block:: python
import urllib3
http = urllib3.PoolManager(num_pools=2)
resp1 = http.request("GET", "https://google.com/")
resp2 = http.request("GET", "https://google.com/mail")
resp3 = http.request("GET", "https://yahoo.com/")
print(len(http.pools))
# 2
NrA<00>proxyrD<00> proxy_config<69>
<00> num_pools<6C>intrZ<00>typing.Mapping[str, str] | None<6E>connection_pool_kw<6B>
typing.AnyrW<00>Nonec s4t<00><00>|<02>||_|t|<01>|_t|_t<06><07>|_dS<00>N)<08>super<65>__init__rxr<00>pools<6C>pool_classes_by_scheme<6D>key_fn_by_schemer_)<04>selfrurZrx<00><01> __class__rQrRr}<00>s 
zPoolManager.__init__rcCs|Sr{rQ<00>r<>rQrQrR<00> __enter__<5F>szPoolManager.__enter__<5F>exc_type<70>type[BaseException] | None<6E>exc_val<61>BaseException | None<6E>exc_tb<74>TracebackType | None<6E>typing.Literal[False]cCs |<00><00>dS)NF)<01>clear)r<>r<>r<>r<>rQrQrR<00>__exit__<5F>szPoolManager.__exit__rXr)rY<00>portrU<00>dict[str, typing.Any] | Noner
cCsx|j|}|dur|j<01><02>}|<04>d<02>durt|d<dD]}|<04>|d<01>q|dkr3tD]}|<04>|d<01>q*|||fi|<04><01>S)a<>
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and
any additional pool keyword arguments.
If ``request_context`` is provided, it is provided as keyword arguments
to the pool class used. This method is used to actually create the
connection pools handed out by :meth:`connection_from_url` and
companion methods. It is intended to be overridden for customization.
N<> blocksize)rXrYr<>rp)rrxr_rcrirg<00> SSL_KEYWORDS)r<>rXrYr<>rU<00>pool_clsrk<00>kwrQrQrR<00> _new_pool<6F>s

zPoolManager._new_poolcCs|j<00><01>dS)z<>
Empty our store of pools and direct them all to close.
This will not affect in-flight connections, but they will not be
re-used after completion.
N)r~r<>r<>rQrQrRr<> szPoolManager.clearrpr2r,<00> pool_kwargscCsT|std<01><01>|<00>|<04>}|pd|d<|st<02>|d<00><04>d<04>}||d<||d<|<00>|<05>S)a<>
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme.
If ``port`` isn't given, it will be derived from the ``scheme`` using
``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is
provided, it is merged with the instance's ``connection_pool_kw``
variable and used to create the new connection pool, if one is
needed.
zNo host specified.rprX<00>Pr<>rY)r <00>_merge_pool_kwargsr rcr`<00>connection_from_context)r<>rYr<>rXr<>rUrQrQrR<00>connection_from_hosts
 
z PoolManager.connection_from_hostrVcCsXd|vrt<00>dt<02>|<01>d<01>|d<00><04>}|j<05>|<02>}|s!t|<02><01>||<01>}|j||d<04>S)z<>
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context.
``request_context`` must at least contain the ``scheme`` key and its
value must be a key in ``key_fn_by_scheme`` instance variable.
<20>strictzdThe 'strict' parameter is no longer needed on Python 3+. This will raise an error in urllib3 v2.1.0.rX<00>rU) <09>warnings<67>warn<72>DeprecationWarningrgr`r<>rcr<00>connection_from_pool_key)r<>rUrX<00>pool_key_constructor<6F>pool_keyrQrQrRr<>1s <04>
  z#PoolManager.connection_from_contextr<74>r(cCs<>|jj<01>4|j<00>|<01>}|r|Wd<00>S|d}|d}|d}|j||||d<05>}||j|<Wd<00>|S1s;wY|S)a
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key.
``pool_key`` should be a namedtuple that only contains immutable
objects. At a minimum it must have the ``scheme``, ``host``, and
``port`` fields.
NrXrYr<>r<>)r~<00>lockrcr<>)r<>r<>rU<00>poolrXrYr<>rQrQrRr<>Js
<10> 
<EFBFBD><10>z$PoolManager.connection_from_pool_key<65>urlcCs t|<01>}|j|j|j|j|d<01>S)a<>
Similar to :func:`urllib3.connectionpool.connection_from_url`.
If ``pool_kwargs`` is not provided and a new pool needs to be
constructed, ``self.connection_pool_kw`` is used to initialize
the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
is provided, it is used instead. Note that if a new pool does not
need to be created for the request, the provided ``pool_kwargs`` are
not used.
)r<>rXr<>)rr<>rYr<>rX)r<>r<>r<><00>urQrQrR<00>connection_from_urlds <06>zPoolManager.connection_from_url<72>overridec CsR|j<00><01>}|r'|<01><02>D]\}}|dur"z||=Wq ty!Yq w|||<q |S)a
Merge a dictionary of override values for self.connection_pool_kw.
This does not modify self.connection_pool_kw and returns a new dict.
Any keys in the override dictionary with a value of ``None`` are
removed from the merged dictionary.
N)rxr_rb<00>KeyError)r<>r<><00>base_pool_kwargsrk<00>valuerQrQrRr<>vs

 <02>
zPoolManager._merge_pool_kwargs<67>
parsed_urlr<00>boolcCs"|jdurdSt|j|j|j<03> S)z<>
Indicates if the proxy requires the complete destination URL in the
request. Normally this is only needed when not using an HTTP CONNECT
tunnel.
NF)rrrrsrX)r<>r<>rQrQrR<00>!_proxy_requires_url_absolute_form<72>s
 <06>z-PoolManager._proxy_requires_url_absolute_formT<6D>method<6F>redirectr<74>rc Ks<>t|<02>}|jdurtjdtdd<04>|j|j|j|jd<05>}d|d<d|d<d |vr-|j|d <|<00> |<05>r=|j
||fi|<04><01>}n |j
||j fi|<04><01>}|oM|<07> <0C>}|sR|St ||<08>}|jd
krld }d|d <t|d <00><01><10>|d <|<04>d <0A>} t| t<13>s}tj| |d<0E>} | jr<>|<06>|<08>s<>|d <00><17>}
|d D]} | <0B><18>| jvr<>|
<EFBFBD>| d<01>q<>|
|d <z | j||||d<0F>} Wnty<>| jr<>|<07><1D><00>|YSw| |d <||d<t<1E>d||<08>|<07><1D>|j
||fi|<04><01>S)aN
Same as :meth:`urllib3.HTTPConnectionPool.urlopen`
with custom cross-host redirect logic and only sends the request-uri
portion of the ``url``.
The given ``url`` parameter must be absolute, such that an appropriate
:class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
Na URLs without a scheme (ie 'https://') are deprecated and will raise an error in a future version of urllib3. To avoid this DeprecationWarning ensure all URLs start with 'https://' or 'http://'. Read more in this issue: https://github.com/urllib3/urllib3/issues/2920<32>)<02>category<72>
stacklevel)r<>rXF<>assert_same_hostr<74>rZi/<00>GET<45>body<64>retries)r<>)<02>response<73>_poolzRedirecting %s -> %s) rrXr<>r<>r<>r<>rYr<>rZr<><00>urlopen<65> request_uri<72>get_redirect_locationr<00>statusr<00>_prepare_for_method_changerc<00>
isinstancer<00>from_int<6E>remove_headers_on_redirect<63> is_same_hostr_r`rg<00> incrementr<00>raise_on_redirect<63>
drain_conn<EFBFBD>log<6F>info) r<>r<>r<>r<>r<>r<><00>connr<6E><00>redirect_locationr<6E><00> new_headers<72>headerrQrQrRr<><00>s`
<06> 

 




<04>   <02> <02>zPoolManager.urlopen)rtN)rurvrZrwrxryrWrz)rWr)r<>r<>r<>r<>r<>r<>rWr<>r{)
rXr)rYr)r<>rvrUr<>rWr
)rWrz<00>NrpN<>
rYr2r<>r,rXr2r<>r<>rWr
)rUrVrWr
)r<>r(rUrVrWr
)r<>r)r<>r<>rWr
)r<>r<>rWrV)r<>rrWr<><00>T<>
r<EFBFBD>r)r<>r)r<>r<>r<>ryrWr)rLrMrNrOrrrPrsr}r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<><00> __classcell__rQrQr<>rRr<00>s0
 ! <10>

 <0C>
&  <0C>

 <0C>

<14>rcsheZdZdZ       d/d0<64>fdd<19> Z   d1d2<64>fd"d#<23> Z d3d4d&d'<27>Z (d5d6<64>fd-d.<2E> Z<07>ZS)7ra>
Behaves just like :class:`PoolManager`, but sends all requests through
the defined proxy, using the CONNECT method for HTTPS URLs.
:param proxy_url:
The URL of the proxy to be used.
:param proxy_headers:
A dictionary containing headers that will be sent to the proxy. In case
of HTTP they are being sent with each request, while in the
HTTPS/CONNECT case they are sent only once. Could be used for proxy
authentication.
:param proxy_ssl_context:
The proxy SSL context is used to establish the TLS connection to the
proxy when using HTTPS proxies.
:param use_forwarding_for_https:
(Defaults to False) If set to True will forward requests to the HTTPS
proxy to be made on behalf of the client instead of creating a TLS
tunnel via the CONNECT method. **Enabling this flag means that request
and response headers and content will be visible from the HTTPS proxy**
whereas tunneling keeps request and response headers and content
private. IP address, target hostname, SNI, and port are always visible
to an HTTPS proxy even when this flag is disabled.
:param proxy_assert_hostname:
The hostname of the certificate to verify against.
:param proxy_assert_fingerprint:
The fingerprint of the certificate to verify against.
Example:
.. code-block:: python
import urllib3
proxy = urllib3.ProxyManager("https://localhost:3128/")
resp1 = proxy.request("GET", "https://google.com/")
resp2 = proxy.request("GET", "https://httpbin.org/")
print(len(proxy.pools))
# 1
resp3 = proxy.request("GET", "https://httpbin.org/")
resp4 = proxy.request("GET", "https://twitter.com/")
print(len(proxy.pools))
# 3
rtNF<4E> proxy_urlr)rurvrZrw<00> proxy_headers<72>proxy_ssl_contextr=<00>use_forwarding_for_httpsr<73><00>proxy_assert_hostname<6D>"None | str | typing.Literal[False]<5D>proxy_assert_fingerprintr2rxryrWrzc  s<>t|t<01>r|j<02>d|j<03>d|j<04><00>}
n|}
t|
<EFBFBD>} | jdvr#t| j<02><01>| js3t<07>| jd<04>} | j | d<05>} | |_
|p9i|_ ||_ t ||||<08>|_|j
| d<|j | d<|j| d<t<0F>j||fi| <09><01>dS) Nz://<2F>:ror<>)r<><00>_proxyr[<00> _proxy_config)r<>r
rXrYr<>rrr rc<00>_replacerrr<>r<>r rsr|r}) r<>r<>rurZr<>r<>r<>r<>r<>rx<00> str_proxy_urlrrr<>r<>rQrRr}#s,


 
<06>


zProxyManager.__init__rprYr<>r,rXr<>r<>r
cs<|dkrt<00>j||||d<02>St<00>j|jj|jj|jj|d<02>S)Nrq)r<>)r|r<>rrrYr<>rX)r<>rYr<>rXr<>r<>rQrRr<>Ls<06><06>z!ProxyManager.connection_from_hostr<74><00>typing.Mapping[str, str]cCs0ddi}t|<01>j}|r||d<|r|<03>|<02>|S)z<>
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
<20>Acceptz*/*<2A>Host)r<00>netloc<6F>update)r<>r<>rZ<00>headers_r<5F>rQrQrR<00>_set_proxy_headers\s

zProxyManager._set_proxy_headersTr<54>r<>r<>rc sRt|<02>}t|j|j|j<04>s|<04>d|j<06>}|<00>||<06>|d<t<08>j ||fd|i|<04><01>S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rZr<>)
rrrrrsrXrcrZr<>r|r<>)r<>r<>r<>r<>r<>r<>rZr<>rQrRr<>ms
zProxyManager.urlopen)rtNNNFNN)r<>r)rurvrZrwr<>rwr<>r=r<>r<>r<>r<>r<>r2rxryrWrzr<>r<>r{)r<>r)rZrwrWr<>r<>r<>) rLrMrNrOr}r<>r<>r<>r<>rQrQr<>rRr<00>s$9<10>,<10> <0C><18>rr<>r)r<>rycKstdd|i|<01><01>S)Nr<4E>rQ)r)r<>r<>rQrQrRr|sr)rSrTrUrVrWr()r<>r)r<>ryrWr):<3A>
__future__r<00> functools<6C>logging<6E>typingr<67><00>typesr<00> urllib.parser<00> _collectionsrr<00>_request_methodsr<00>
connectionr <00>connectionpoolr
r r <00>
exceptionsr rrrr<>r<00>util.connectionr<00>
util.proxyr<00>
util.retryr<00> util.timeoutr<00>util.urlrr<00> TYPE_CHECKING<4E>ssl<73>typing_extensionsr<00>__all__<5F> getLoggerrLr<>r<>ri<00>
NamedTupler(rn<00>partialr<6C>rrrrrQrQrQrR<00><module>sJ           

'
<
<06>
L