Re,TdZddlZddlZddlmZmZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2mZmZm3Z3m4Z4m5Z5m6Z6ddl7m8Z8 ddl9m:Z:n#e;$rdZ:YnwxYwdZdZ?Gdd e@ZAGd!d"eAZBdS)#z requests.adapters ~~~~~~~~~~~~~~~~~ This module contains the transport adapters that Requests uses to define and maintain connections. N) PoolManagerproxy_from_url) HTTPResponse) parse_url)Timeout)Retry)ClosedPoolError)ConnectTimeoutError) HTTPError) MaxRetryError)NewConnectionError) ProxyError) ProtocolError)ReadTimeoutError)SSLError) ResponseError)LocationValueError)Response)urlparse basestring)DEFAULT_CA_BUNDLE_PATHextract_zipped_pathsget_encoding_from_headersprepend_scheme_if_neededget_auth_from_url urldefragauth select_proxy)CaseInsensitiveDict)extract_cookies_to_jar) ConnectionErrorConnectTimeout ReadTimeoutrr RetryError InvalidSchemaInvalidProxyURL InvalidURL)_basic_auth_str)SOCKSProxyManagerc td)Nz'Missing dependencies for SOCKS support.)r%)argskwargss /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/requests/adapters.pyr)r).sEFFFF c4eZdZdZfdZ ddZdZxZS) BaseAdapterzThe Base Transport AdaptercVtt|dSN)superr1__init__)self __class__s r-r5zBaseAdapter.__init__:s% k4  ))+++++r.FNTct)aCSends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest ` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. NotImplementedError)r6requeststreamtimeoutverifycertproxiess r-sendzBaseAdapter.send=s "!r.ct)z!Cleans up adapter specific items.r9r6s r-closezBaseAdapter.closeOs!!r.FNTNN)__name__ __module__ __qualname____doc__r5rArD __classcell__r7s@r-r1r17sk$$,,,,,@D $""""$"""""""r.r1ceZdZdZgdZeeeeffd ZdZ dZ efdZ dZ dZ d Zdd Zd Zd ZdZdZddZxZS) HTTPAdapteraThe built-in HTTP Adapter for urllib3. Provides a general-case interface for Requests sessions to contact HTTP and HTTPS urls by implementing the Transport Adapter interface. This class will usually be created by the :class:`Session ` class under the covers. :param pool_connections: The number of urllib3 connection pools to cache. :param pool_maxsize: The maximum number of connections to save in the pool. :param max_retries: The maximum number of retries each connection should attempt. Note, this applies only to failed DNS lookups, socket connections and connection timeouts, never to requests where data has made it to the server. By default, Requests does not retry failed connections. If you need granular control over the conditions under which we retry a request, import urllib3's ``Retry`` class and pass that instead. :param pool_block: Whether the connection pool should block for connections. Usage:: >>> import requests >>> s = requests.Session() >>> a = requests.adapters.HTTPAdapter(max_retries=3) >>> s.mount('http://', a) ) max_retriesconfig_pool_connections _pool_maxsize _pool_blockcB|tkrtdd|_ntj||_i|_i|_t t|||_ ||_ ||_ | |||dS)NrF)readblock) DEFAULT_RETRIESrrNfrom_intrO proxy_managerr4rMr5rPrQrRinit_poolmanager)r6pool_connections pool_maxsizerN pool_blockr7s r-r5zHTTPAdapter.__init__qs / ) )$QU333D  $~k::D   k4  ))+++!1)% . JOOOOOr.c*fdjDS)Nc4i|]}|t|dSr3)getattr).0attrr6s r- z,HTTPAdapter.__getstate__..s'KKKDgdD$//KKKr.) __attrs__rCs`r- __getstate__zHTTPAdapter.__getstate__sKKKKDNKKKKr.ci|_i|_|D]\}}t|||||j|j|jdS)NrU)rYrOitemssetattrrZrPrQrR)r6staterbvalues r- __setstate__zHTTPAdapter.__setstate__sz   ;;== ' 'KD% D$ & & & & d4d6H$($4  6 6 6 6 6r.c \||_||_||_td|||dd||_dS)aInitializes a urllib3 PoolManager. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param connections: The number of urllib3 connection pools to cache. :param maxsize: The maximum number of connections to save in the pool. :param block: Block when no free connections are available. :param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager. T) num_poolsmaxsizerVstrictN)rPrQrRr poolmanager)r6 connectionsrnrV pool_kwargss r-rZzHTTPAdapter.init_poolmanagersT"-$ &Pg-24PPCNPPr.c ||jvr|j|}n|dr?t|\}}t |f|||j|j|jd|x}|j|<n@||}t|f||j|j|jd|x}|j|<|S)aReturn urllib3 ProxyManager for the given proxy. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param proxy: The proxy to return a urllib3 ProxyManager for. :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager. :returns: ProxyManager :rtype: urllib3.ProxyManager socks)usernamepasswordrmrnrV) proxy_headersrmrnrV) rYlower startswithrr)rPrQrRrxr)r6proxy proxy_kwargsmanagerrvrwrxs r-proxy_manager_forzHTTPAdapter.proxy_manager_fors D& & &(/GG [[]] % %g . . !25!9!9 Hh2C3!!0*& 3333 Gd(//!..u55M2@3 +0*& 3 3  3 3  Gd(/r.c|dr|rd}|dur|}|stt}|rtj|s"td|d|_ tj |s||_ n||_ nd|_ d|_ d|_ |rt|ts|d|_|d|_n||_d|_|jrKtj|js'td |j|jrMtj|js+td |jdSdSdS) aAVerify a SSL certificate. This method should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param conn: The urllib3 connection object associated with the cert. :param url: The requested URL. :param verify: Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use :param cert: The SSL certificate to verify. httpsNTzECould not find a suitable TLS CA certificate bundle, invalid path: {} CERT_REQUIRED CERT_NONErrz9Could not find the TLS certificate file, invalid path: {}z1Could not find the TLS key file, invalid path: {})ryrzrrospathexistsIOErrorformat cert_reqsisdirca_certs ca_cert_dir isinstancer cert_filekey_file)r6connurlr>r?cert_locs r- cert_verifyzHTTPAdapter.cert_verifys 99;; ! !' * * $v $HT!!! H/0FGG C27>>(#;#; C1171A1ACCC-DN7==** , ( #+  (DN DM#D   HdJ// %!%a $Q !% $ ~ IbgnnT^&D&D I1171G1GIII} HRW^^DM%B%B H117 1F1FHHH H H H H H Hr.ct}t|dd|_tt|di|_t |j|_||_|jj|_t|j tr |j d|_ n |j |_ t|j||||_||_|S)aBuilds a :class:`Response ` object from a urllib3 response. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter ` :param req: The :class:`PreparedRequest ` used to generate the response. :param resp: The urllib3 response object. :rtype: requests.Response statusNheadersutf-8)rr` status_coderrrencodingrawreasonrrbytesdecoder cookiesr; connection)r6reqrespresponses r-build_responsezHTTPAdapter.build_responses:: 'tXt<</wtY/K/KLL6h6FGG ",- cgu % % #7>>'22HLL7HL x/d;;;"r.Ncdt||}|r`t|d}t|}|jst d||}||}n=t|}|}|j |}|S)aReturns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param url: The URL to connect to. :param proxies: (optional) A Requests-style dictionary of proxies used on this request. :rtype: urllib3.ConnectionPool httpzFPlease check proxy URL. It is malformed and could be missing the host.) rrrhostr&r~connection_from_urlrgeturlrq)r6rr@r{ proxy_urlrYrparseds r-get_connectionzHTTPAdapter.get_connection$sS'**  =,UF;;E!%((I> I%'HIII 22599M 44S99DDc]]F--//C#77<`. :param request: The :class:`PreparedRequest ` being sent. :param proxies: A dictionary of schemes or schemes and hosts to proxy URLs. :rtype: str rFru)rrrschemeryrzpath_urlr) r6r;r@r{ris_proxied_http_requestusing_socks_proxy proxy_schemers r- request_urlzHTTPAdapter.request_urlIsW['22'+&&-#(#>Vw->!  A#E??17799L , 7 7 @ @  " -+< - ,,C r.c dS)a"Add any headers needed by the connection. As of v2.0 this does nothing by default, but is left for overriding by users that subclass the :class:`HTTPAdapter `. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param request: The :class:`PreparedRequest ` to add headers to. :param kwargs: The keyword arguments from the call to send(). Nrp)r6r;r,s r- add_headerszHTTPAdapter.add_headersfs  r.cXi}t|\}}|rt|||d<|S)aReturns a dictionary of the headers to add to any request sent through a proxy. This works with urllib3 magic to ensure that they are correctly sent to the proxy, rather than in a tunnelled request if CONNECT is being used. This should not be called from user code, and is only exposed for use when subclassing the :class:`HTTPAdapter `. :param proxy: The url of the proxy being used for this request. :rtype: dict zProxy-Authorization)rr()r6r{rrvrws r-rxzHTTPAdapter.proxy_headerstsG.u55(  G-` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) ` tuple. :type timeout: float or tuple or urllib3 Timeout object :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. :rtype: requests.Response )r;N)r<r=r>r?r@zContent-Length)connectrTzrInvalid timeout {}. Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same valueF) methodrbodyrredirectassert_same_hostpreload_contentdecode_contentretriesr= proxy_pool)r=T)skip_accept_encodingrs s0 ) buffering)poolrrr)6rrrr'rrrrrrtuple TimeoutSauce ValueErrorrurlopenrrNhasattrr _get_connDEFAULT_POOL_TIMEOUT putrequestrg putheader endheadersrAhexlenencode getresponse TypeErrorr from_httplibrDrsocketerrorr!r rr r r"rr$ _ProxyErrorr _SSLErrorrr _HTTPErrorrr#r)r6r;r<r=r>r?r@rerchunkedrrTerrrlow_connheaderrjirs r-rAzHTTPAdapter.sendsf" 1&&w{G< #O"%*$)#( ,#$  4..+?D>>2F>GG$''(+=A(CCC*1)>)>)@)@::  **659999'')))$\// c#a&&kk!""o&<&??=(G<<<<!(M22 5 G4444!(K00 5 G4444!(I.. 3q'2222!!W555 5 6 6 6!!W555 5   Q-- :&   !Y'' q'2222A/00 !!W5555 ""7D111s >9>8C D$C==D-A)LDK;&J=<K;=KK;KK;:L;LLS-L>> S CP"" S/Q S QS0A R==Sr3rE)rFrGrHrIrdDEFAULT_POOLSIZErWDEFAULT_POOLBLOCKr5rerkrZr~rrrrDrrrxrArJrKs@r-rMrMTsI2   I)9.O-PPPPPP$LLL 6 6 6rs` GGGGGGGG555555......<<<<<<000000::::::>>>>>>BBBBBB888888======DDDDDD888888;;;;;;@@@@@@888888======((((((((DDDDDDDDDDDDDDDDDD,+++++++++++%%%%%%%%%%%%%%%%%%%%%%"!!!!!GCCCCCCCGGGGGGGGG"""""&""":A2A2A2A2A2+A2A2A2A2A2s6B==CC