8fNddlmZddlZddlZddlZddlmZmZddlm Z m Z m Z ddl m Z mZmZmZmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZgd Zeje Z!dZ"dZ#ej$de#Z%dZ&ej$de&Z'dZ(ej)e(e%ej)e(e%dZ*e e dZ+GddeZ,Gdde,Z-dZ.dS))absolute_importN)HTTPHeaderDictRecentlyUsedContainer)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_passwordserver_hostname) 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/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/urllib3/poolmanager.py_default_key_normalizerrXOs8*""$$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||_t |_t |_dSN)r__init__connection_pool_kwrpoolspool_classes_by_schemekey_fn_by_schemerG)self num_poolsrArbs rWrazPoolManager.__init__sPg..."4*955 '=# 0 5 5 7 7rYc|Sr`rFrfs rW __enter__zPoolManager.__enter__s rYc.|dS)NF)clear)rfexc_typeexc_valexc_tbs rW__exit__zPoolManager.__exit__s urYc|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@portr[)rdrbrGrO SSL_KEYWORDS)rfr?r@rrrRpool_clsrTkws rW _new_poolzPoolManager._new_pools.v6  ""5::<>$*$4f! M!%oh&?&E&E&G&GLLD"&"&++O<<>(++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. )rrr?r|)rr}r@rrr?)rfurlr|us rWconnection_from_urlzPoolManager.connection_from_urls; cNN(( Fk)   rYc|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. )rbrGrJKeyError)rfoverridebase_pool_kwargsrTvalues rWrzzPoolManager._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?)rf parsed_urls rW!_proxy_requires_url_absolute_formz-PoolManager._proxy_requires_url_absolute_formCs7 : 52 J):+<    rYc|j|dkrdS|jjdkrdStjr|jjst ddSdS)z Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. Nr\zfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2)rr?rPY2rr<r )rf url_schemes rW$_validate_proxy_scheme_url_selectionz0PoolManager._validate_proxy_scheme_url_selectionPss : w!6!6 F :  ' ' F 7 4,E (E     rYTc t|}||j||j|j|j}d|d<d|d<d|vr|j|d<||r|j ||fi|}n|j ||j fi|}|o| }|s|St||}|j dkr1d}d|d <t|d|d<|d } t#| t$st%j| | } | jrx||sct-t/j|d} | D]9} | | jvr|d| d: | |||| } n.#t8$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. )rrr?Fassert_same_hostredirectrAi/GETNbodyretries)r)response_poolzRedirecting %s -> %s)!rrr?r}r@rrrArGrurlopen request_uriget_redirect_locationrstatusr_prepare_for_method_changerK isinstancerfrom_intremove_headers_on_redirect is_same_hostrMriterkeysrHrO incrementr raise_on_redirect drain_connloginfo) rfmethodrrrurconnrredirect_locationrrAheaders rWrzPoolManager.urlopenas 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 ! !FBvJ*2i=99TTVVByM&&##'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:%irZry)rr_proxyrB _proxy_config)rrr?r@rrrr r rK_replacer proxy_headersproxy_ssl_contextr=rsuperrra) rf proxy_urlrgrArrr<rbrrr __class__s rWrazProxyManager.__init__s i!3 4 4 $ (I )$$ <0 0 0$U\22 2z .!%elB77DNNN--E *0b!2'(9;STT'+z8$/3/A+,.2.??+*lD!!*9gTTASTTTTTrYr[c|dkr,tt|||||Stt||jj|jj|jj|S)Nr\)r|)rrr}rr@rrr?)rfr@rrr?r|rs rWr}z!ProxyManager.connection_from_hosts~ W  t,,AAdF B \4((== JOTZ_dj.?[>   rYcrddi}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)rfrrAheaders_rs rW_set_proxy_headerszProxyManager._set_proxy_headerssM e$3&  &%HV   % OOG $ $ $rYTc t|}t|j|j|js4|d|j}||||d<tt|j ||fd|i|S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rAr) rrrrr?rKrArrrr)rfrrrrurrArs rWrzProxyManager.urlopens cNN.tz4;LahWW BffY 55G 33CAAByM0u\4((0VVxVSUVVVrY)r^NNNFrr`r) rrrrrar}rr __classcell__)rs@rWrrs%%T!&#U#U#U#U#U#UJ           W W W W W W W W W WrYrc tdd|i|S)NrrF)r)rrus rWrrs  , ,# , , ,,rY)/ __future__r collections functoolslogging _collectionsrrconnectionpoolrrr exceptionsr r r r rpackagesrpackages.six.moves.urllib.parserrequestr util.proxyr util.retryrutil.urlr__all__ getLoggerrrrs _key_fields namedtupler;_proxy_config_fieldsr=rXpartialrerdrrrrFrYrWrs]&&&&&&????????SSSSSSSSSS444444######777777 ; ; ;g!!   > !+ K 8 8B$k$]4HII . . . l I 5w ? ? Y 6 @ @ #5?RSSY=Y=Y=Y=Y=.Y=Y=Y=xpWpWpWpWpW;pWpWpWf-----rY