Re3MddlmZddlZddlZddlZddlmZddlmZm Z m Z ddl m Z m Z mZmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZgd ZejeZ dZ!dZ"ej#de"Z$dZ%ej#de%Z&dZ'ej(e'e$ej(e'e$dZ)ee dZ*GddeZ+Gdde+Z,dZ-dS))absolute_importN)RecentlyUsedContainer)HTTPConnectionPoolHTTPSConnectionPoolport_by_scheme)LocationValueError MaxRetryErrorProxySchemeUnknownProxySchemeUnsupportedURLSchemeUnknown)six)urljoin)RequestMethods)connection_requires_http_tunnel)Retry) parse_url) PoolManager ProxyManagerproxy_from_url)key_file cert_file cert_reqsca_certs ssl_version ca_cert_dir ssl_context key_password) key_schemekey_hostkey_port key_timeout key_retries key_strict key_blockkey_source_address key_key_filekey_key_password key_cert_file key_cert_reqs key_ca_certskey_ssl_versionkey_ca_cert_dirkey_ssl_context key_maxsize key_headers key__proxykey__proxy_headerskey__proxy_configkey_socket_optionskey__socks_optionskey_assert_hostnamekey_assert_fingerprintkey_server_hostnamePoolKey)ruse_forwarding_for_https ProxyConfigc|}|d|d<|d|d<dD]8}||vr2||*t||||<9|d}|t ||d<t |D]}|||d|z<|j D] }||vrd||< |di|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 schemehost)headers_proxy_headers_socks_optionsNsocket_optionskey_) copylower frozensetitemsgettuplelistkeyspop_fields) key_classrequest_contextcontextkey socket_optsfields /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/urllib3/poolmanager.py_default_key_normalizerrVNs8*""$$G)//11GHfo++--GFO?;; '>>gcl6$WS\%7%7%9%9::GCL++.//K$)+$6$6 !GLLNN##11 ' C 0 0 """   !GEN 9  w  httphttpscteZdZdZdZdZddZdZdZddZ dZ dd Z d Z dd Z dd ZdZdZdZddZdS)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 c tj||||_t|d|_t |_t |_dS)Nc*|SN)close)ps rUz&PoolManager.__init__..sQWWYYrW) dispose_func)r__init__connection_pool_kwrpoolspool_classes_by_schemekey_fn_by_schemerE)self num_poolsr?res rUrdzPoolManager.__init__sYg..."4*9CVCVWWW '=# 0 5 5 7 7rWc|Sr_rDris rU __enter__zPoolManager.__enter__s rWc.|dS)NF)clear)riexc_typeexc_valexc_tbs rU__exit__zPoolManager.__exit__s urWc|j|}||j}dD]}||d|dkr tD]}||d|||fi|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)r=r>portrY)rgrerErM SSL_KEYWORDS)rir=r>rurPpool_clsrRkws rU _new_poolzPoolManager._new_pools.v6  ""5::<)r _merge_pool_kwargsrrIrFconnection_from_context)rir>rur= pool_kwargsrPs rUconnection_from_hostz PoolManager.connection_from_hosts ;$%9:: :11+>>$*$4f! M!%oh&?&E&E&G&GLLD"&"&++O<<rur)rflockrIry)rirrPpoolr=r>rus rUrz$PoolManager.connection_from_pool_keysZ_ ( (:>>(++D  ( ( ( ( ( ( ( (%X.F"6*D"6*D>>&$o>VVD#'DJx  ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( sA?;A??BBcpt|}||j|j|j|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. )rur=r)rrr>rur=)riurlrus rUconnection_from_urlzPoolManager.connection_from_urls; cNN(( Fk)   rWc|j}|r6|D]!\}}| ||= #t$rYwxYw|||<"|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. )rerErHKeyError)rioverridebase_pool_kwargsrRvalues rUr}zPoolManager._merge_pool_kwargs.s 27799  2&nn.. 2 2 U=,S11#-2$S))s< A A cV|jdSt|j|j|j 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)proxyr proxy_configr=)ri parsed_urls rU!_proxy_requires_url_absolute_formz-PoolManager._proxy_requires_url_absolute_formBs7 : 52 J):+<    rWc|j|dkrdS|jjdkrdStjr|jjst ddSdS)z Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. NrZzfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2)rr=rPY2rr:r )ri url_schemes rU$_validate_proxy_scheme_url_selectionz0PoolManager._validate_proxy_scheme_url_selectionOss : w!6!6 F :  ' ' F 7 4,E (E     rWTc xt|}||j||j|j|j}d|d<d|d<d|vr|j|d<||r|j ||fi|}n|j ||j fi|}|o| }|s|St||}|j dkrd}|d} t| t st!j| | } | jrx||sct)t+j|d} | D]9} | | jvr|d| d : | |||| } n.#t4$r!| jr||cYSwxYw| |d<||d<t:d ||||j ||fi|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. )rur=Fassert_same_hostredirectr?i/GETretries)rN)response_poolzRedirecting %s -> %s)rrr=rr>rur?rErurlopen request_uriget_redirect_locationrstatusrI isinstancerfrom_intremove_headers_on_redirect is_same_hostrKriterkeysrFrM incrementr raise_on_redirect drain_connloginfo) rimethodrrrxrconnrredirect_locationrr?headers rUrzPoolManager.urlopen`s cNN 11!(;;;((afQX(NN!& : B   L--//ByM  1 1! 4 4 A#t|FC66266HH#t|FAM@@R@@H$I)G)G)I)I  O$C):;; ?c ! !F&&##'5)) AnWx@@@G  - 4d6G6G 7 7  43<9 6677G! 4 4<<>>W%GGGyM%%fd333 ''hd'SSGG   ( ##%%%OOO    9 !: '.?@@@t|F$5<<<< 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. 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 r\NFc t|trd|j|j|jfz}t |}|jdvrt |j|js0tj|jd} | | }||_ |pi|_ ||_ t|||_|j |d<|j |d<|j|d<tt |j||fi|dS)Nz %s://%s:%irXr|)ru_proxyr@ _proxy_config)rrr=r>rurr rrI_replacer proxy_headersproxy_ssl_contextr;rsuperrrd) ri proxy_urlrjr?rrr:rerru __class__s rUrdzProxyManager.__init__s i!3 4 4 $ (I )$$ <0 0 0$U\22 2z .!%elB77DNNN--E *0b!2'(9;STT'+z8$/3/A+,.2.??+*lD!!*9gTTASTTTTTrWrYc|dkr,tt|||||Stt||jj|jj|jj|S)NrZ)r)rrrrr>rur=)rir>rur=rrs rUrz!ProxyManager.connection_from_hosts~ W  t,,AAdF B \4((== JOTZ_dj.?[>   rWcrddi}t|j}|r||d<|r|||S)z Sets headers needed by proxies: specifically, the Accept and Host headers. Only sets headers not provided by the user. Acceptz*/*Host)rnetlocupdate)rirr?headers_rs rU_set_proxy_headerszProxyManager._set_proxy_headerssM e$3&  &%HV   % OOG $ $ $rWTc t|}t|j|j|js4|d|j}||||d<tt|j ||fd|i|S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.r?r) rrrrr=rIr?rrrr)rirrrrxrr?rs rUrzProxyManager.urlopen s cNN.tz4;LahWW BffY 55G 33CAAByM0u\4((0VVxVSUVVVrW)r\NNNFrr_r) rrrrrdrrr __classcell__)rs@rUrrs%%T!&#U#U#U#U#U#UJ           W W W W W W W W W WrWrc tdd|i|S)NrrD)r)rrxs rUrrs  , ,# , , ,,rW). __future__r collections functoolslogging _collectionsrconnectionpoolrrr exceptionsr r r r r packagesrpackages.six.moves.urllib.parserrequestr util.proxyr util.retryrutil.urlr__all__ getLoggerrrrv _key_fields namedtupler9_proxy_config_fieldsr;rVpartialrhrgrrrrDrWrUrsW&&&&&&//////SSSSSSSSSS444444######777777 ; ; ;g!!   > !+ K 8 8B$k$]4HII . . . l I 5w ? ? Y 6 @ @ #5?RSSV=V=V=V=V=.V=V=V=rpWpWpWpWpW;pWpWpWf-----rW