Files
old-nlp/venv/lib/python3.7/site-packages/urllib3/__pycache__/poolmanager.cpython-37.pyc

200 lines
12 KiB
Plaintext
Raw Normal View History

2019-10-20 13:16:49 +02:00
B
U%<25>]<5D>B<00>@sddlmZddlZddlZddlZddlmZddlmZm Z ddlm
Z
ddl m Z m Z mZddlmZdd lmZdd
lmZdd lmZdd lmZd ddgZe<04>e<1B>ZdZdZe<02>de<1E>Z dd<14>Z!e<03>"e!e <20>e<03>"e!e <20>d<15>Z#ee d<15>Z$Gdd <0A>d e<14>Z%Gdd<0E>de%<25>Z&dd<0F>Z'dS)<19>)<01>absolute_importN<74>)<01>RecentlyUsedContainer)<02>HTTPConnectionPool<6F>HTTPSConnectionPool)<01>port_by_scheme)<03>LocationValueError<6F> MaxRetryError<6F>ProxySchemeUnknown)<01>six)<01>urljoin)<01>RequestMethods)<01> parse_url)<01>Retry<72> PoolManager<65> ProxyManager<65>proxy_from_url)<08>key_file<6C> cert_file<6C> cert_reqs<71>ca_certs<74> ssl_version<6F> ca_cert_dir<69> ssl_context<78> key_password)<19>
key_scheme<EFBFBD>key_host<73>key_port<72> key_timeout<75> key_retries<65>
key_strict<EFBFBD> key_block<63>key_source_address<73> key_key_file<6C>key_key_password<72> key_cert_file<6C> key_cert_reqs<71> key_ca_certs<74>key_ssl_version<6F>key_ca_cert_dir<69>key_ssl_context<78> key_maxsize<7A> key_headers<72>
key__proxy<EFBFBD>key__proxy_headers<72>key_socket_options<6E>key__socks_options<6E>key_assert_hostname<6D>key_assert_fingerprint<6E>key_server_hostname<6D>PoolKeycCs<>|<01><00>}|d<00><01>|d<|d<00><01>|d<x4dD],}||kr.||dk r.t||<00><03><00>||<q.W|<02>d<05>}|dk r|t|<04>|d<x&t|<02><07><00>D]}|<02>|<03>|d|<q<>Wx|j D]}||kr<>d||<q<>W|f|<02>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_)
<EFBFBD>copy<70>lower<65> frozenset<65>items<6D>get<65>tuple<6C>list<73>keys<79>pop<6F>_fields)<06> key_class<73>request_context<78>context<78>key<65> socket_opts<74>field<6C>rL<00>8/tmp/pip-install-_zqls8j0/urllib3/urllib3/poolmanager.py<70>_default_key_normalizerDs

   rN)<02>http<74>httpsc@sxeZdZdZdZddd<05>Zdd<07>Zdd <09>Zdd
d <0B>Zd d <0A>Z ddd<10>Z
dd<12>Z ddd<14>Z d dd<16>Z dd<18>Zd!dd<1B>ZdS)"ra$
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::
>>> manager = PoolManager(num_pools=2)
>>> r = manager.request('GET', 'http://google.com/')
>>> r = manager.request('GET', 'http://google.com/mail')
>>> r = manager.request('GET', 'http://yahoo.com/')
>>> len(manager.pools)
2
N<>
cKs8t<00>||<02>||_t|dd<02>d<03>|_t|_t<06><07>|_dS)NcSs|<00><00>S)N)<01>close)<01>prLrLrM<00><lambda><3E><00>z&PoolManager.__init__.<locals>.<lambda>)<01> dispose_func)r <00>__init__<5F>connection_pool_kwr<00>pools<6C>pool_classes_by_scheme<6D>key_fn_by_schemer<)<04>self<6C> num_poolsr7rXrLrLrMrW<00>s
 zPoolManager.__init__cCs|S)NrL)r\rLrLrM<00> __enter__<5F>szPoolManager.__enter__cCs |<00><00>dS)NF)<01>clear)r\<00>exc_type<70>exc_val<61>exc_tbrLrLrM<00>__exit__<5F>szPoolManager.__exit__cCsf|j|}|dkr|j<01><02>}xdD]}|<04>|d<01>q"W|dkrXxtD]}|<04>|d<01>qDW|||f|<04>S)a<>
Create a new :class:`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)r5r6<00>portrO)rZrXr<rD<00> SSL_KEYWORDS)r\r5r6rdrG<00>pool_clsrI<00>kwrLrLrM<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)rYr_)r\rLrLrMr_<00>szPoolManager.clearrOcCsT|s td<01><01>|<00>|<04>}|pd|d<|s:t<02>|d<00><04>d<04>}||d<||d<|<00>|<05>S)a<>
Get a :class:`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.rOr5<00>Prdr6)r<00>_merge_pool_kwargsrr@r=<00>connection_from_context)r\r6rdr5<00> pool_kwargsrGrLrLrM<00>connection_from_host<73>s 
 z PoolManager.connection_from_hostcCs,|d<00><00>}|j|}||<01>}|j||d<02>S)z<>
Get a :class:`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.
r5)rG)r=r[<00>connection_from_pool_key)r\rGr5<00>pool_key_constructor<6F>pool_keyrLrLrMrk<00>s 
z#PoolManager.connection_from_contextc Cs`|jj<01>N|j<00>|<01>}|r|S|d}|d}|d}|j||||d<04>}||j|<WdQRX|S)z<>
Get a :class:`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.
r5r6rd)rGN)rY<00>lockr@rh)r\rprG<00>poolr5r6rdrLrLrMrn<00>s
 z$PoolManager.connection_from_pool_keycCs 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.
)rdr5rl)rrmr6rdr5)r\<00>urlrl<00>urLrLrM<00>connection_from_urls zPoolManager.connection_from_urlc CsZ|j<00><01>}|rVxF|<01><02>D]:\}}|dkrJy
||=WqRtk
rFYqRXq|||<qW|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<r?<00>KeyError)r\<00>override<64>base_pool_kwargsrI<00>valuerLrLrMrj!s

 zPoolManager._merge_pool_kwargsTc Ks<>t|<02>}|j|j|j|jd<01>}d|d<d|d<d|krD|j<05><06>|d<|jdk rj|jdkrj|j||f|<04>}n|j||j f|<04>}|o<>|<07>
<EFBFBD>}|s<>|St ||<08>}|j dkr<>d }|<04> d
<EFBFBD>} t| t<0F>s<>tj| |d <0B>} | j<11>r|<06>|<08><01>stt<14>|d<00><01>}
x*|
D]"} | <0B><16>| jkr<>|d<00>| d<06>q<>Wy| j||||d <0C>} Wn tk
<EFBFBD>rR| j<1A>rN<72>|SX| |d
<||d<t<1B>d ||<08>|j||f|<04>S)a]
Same as :meth:`urllib3.connectionpool.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.
)rdr5F<>assert_same_host<73>redirectr7NrOi/<00>GET<45>retries)r{)<02>response<73>_poolzRedirecting %s -> %s)rrmr6rdr5r7r<<00>proxy<78>urlopen<65> request_uri<72>get_redirect_locationr <00>statusr@<00>
isinstancer<00>from_int<6E>remove_headers_on_redirect<63> is_same_hostrBr <00>iterkeysr=rD<00> incrementr <00>raise_on_redirect<63>log<6F>info) r\<00>methodrsr{rgrt<00>connr~<00>redirect_locationr}r7<00>headerrLrLrMr<>5sD  



 
zPoolManager.urlopen)rQN)N)NrON)N)N)T)<10>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r<5F>rWr^rcrhr_rmrkrnrurjr<>rLrLrLrMr<00>s




csHeZdZdZd<0E>fdd<05> Zd<0F>fdd<08> Zdd d
<EFBFBD>Zd<11>fd d <0A> Z<07>ZS)rax
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.
Example:
>>> proxy = urllib3.ProxyManager('http://localhost:3128/')
>>> r1 = proxy.request('GET', 'http://google.com/')
>>> r2 = proxy.request('GET', 'http://httpbin.org/')
>>> len(proxy.pools)
1
>>> r3 = proxy.request('GET', 'https://httpbin.org/')
>>> r4 = proxy.request('GET', 'https://twitter.com/')
>>> len(proxy.pools)
3
rQNc s<>t|t<01>rd|j|j|jf}t|<01>}|jsFt<06>|jd<02>}|j|d<03>}|jdkrZt |j<02><01>||_
|pfi|_ |j
|d<|j |d<t t |<00>j||f|<05>dS)Nz
%s://%s:%iri)rd)rOrP<00>_proxyr8)r<>rr5r6rdrrr@<00>_replacer
r<><00> proxy_headers<72>superrrW)r\<00> proxy_urlr]r7r<>rXr<>rd)<01> __class__rLrMrW<00>s

 




zProxyManager.__init__rOcsD|dkr tt|<00>j||||d<02>Stt|<00>j|jj|jj|jj|d<02>S)NrP)rl)r<>rrmr<>r6rdr5)r\r6rdr5rl)r<>rLrMrm<00>s


z!ProxyManager.connection_from_hostcCs0ddi}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\rsr7<00>headers_r<5F>rLrLrM<00>_set_proxy_headers<72>s

zProxyManager._set_proxy_headersTc sNt|<02>}|jdkr0|<04>d|j<03>}|<00>||<06>|d<tt|<00>j||fd|i|<04><02>S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rOr7r{)rr5r@r7r<>r<>rr<>)r\r<>rsr{rgrtr7)r<>rLrMr<><00>s

zProxyManager.urlopen)rQNN)NrON)N)T) r<>r<>r<>r<>rWrmr<>r<><00> __classcell__rLrL)r<>rMrts
cKstfd|i|<01><02>S)Nr<4E>)r)rsrgrLrLrMr<00>s)(<28>
__future__r<00> collections<6E> functools<6C>logging<6E> _collectionsr<00>connectionpoolrrr<00>
exceptionsrr r
<00>packagesr Zpackages.six.moves.urllib.parser <00>requestr Zutil.urlrZ
util.retryr<00>__all__<5F> getLoggerr<72>r<>re<00> _key_fields<64>
namedtupler4rN<00>partialr[rZrrrrLrLrLrM<00><module>s2        

  6

ta