bgaLdZddlZddlZddlmZmZddlmZddlm Z ddlm Z m Z m Z mZddlmZddlmZmZdd lmZdd lmZmZdd lmZdd lmZdd lmZddlmZddl m!Z!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm Z m(Z(m)Z)m*Z*mZm+Z+m,Z,mZddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:n#e;$rdZ:YnwxYwdZdZ?GddZ@Gdde@ZAdS)z requests.adapters ~~~~~~~~~~~~~~~~~ This module contains the transport adapters that Requests uses to define and maintain connections. N)ClosedPoolErrorConnectTimeoutError) HTTPError) InvalidHeader)LocationValueError MaxRetryErrorNewConnectionError ProtocolError) ProxyError)ReadTimeoutError ResponseError)SSLError) PoolManagerproxy_from_url)Timeout) parse_url)Retry)_basic_auth_str) basestringurlparse)extract_cookies_to_jar) ConnectionErrorConnectTimeoutrInvalidProxyURL InvalidSchema InvalidURLr ReadTimeout RetryErrorr)Response)CaseInsensitiveDict)DEFAULT_CA_BUNDLE_PATHextract_zipped_pathsget_auth_from_urlget_encoding_from_headersprepend_scheme_if_needed select_proxy urldefragauth)SOCKSProxyManagerc td)Nz'Missing dependencies for SOCKS support.)r)argskwargss H/opt/cloudlinux/venv/lib64/python3.11/site-packages/requests/adapters.pyr)r)<sEFFFF c2eZdZdZfdZ ddZdZxZS) BaseAdapterzThe Base Transport AdaptercHtdSN)super__init__)self __class__s r-r5zBaseAdapter.__init__Is 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.sendLs ""!r.ct)z!Cleans up adapter specific items.r9r6s r-closezBaseAdapter.close_s!!r.FNTNN)__name__ __module__ __qualname____doc__r5rArD __classcell__r7s@r-r1r1Fsh$$TX""""&"""""""r.r1ceZdZdZgdZeeeeffd ZdZ dZ efdZ dZ dZ d Zdd Zd Zd ZdZdZ ddZxZS) 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_blockc4|tkrtdd|_ntj||_i|_i|_t ||_||_ ||_ | |||dS)NrF)readblock) DEFAULT_RETRIESrrNfrom_intrO proxy_managerr4r5rPrQrRinit_poolmanager)r6pool_connections pool_maxsizerN pool_blockr7s r-r5zHTTPAdapter.__init__s / ) )$QU333D  $~k::D   !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$ & & & &   "D$6d>N      r.c Z||_||_||_td|||d||_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. ) num_poolsmaxsizerVN)rPrQrRr poolmanager)r6 connectionsrnrV pool_kwargss r-rZzHTTPAdapter.init_poolmanagersQ"-$ & !     r.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 startswithr$r)rPrQrRrwr)r6proxy proxy_kwargsmanagerrurvrws r-proxy_manager_forzHTTPAdapter.proxy_manager_fors D& & &(/GG [[]] % %g . . !25!9!9 Hh2C3!!0*& 3333 Gd(//!..u55M2@3+0*& 33  33 Gd(/r.c |dr|rd}|dur|}|stt}|rtj|std|d|_tj |s||_ n||_ nd|_d|_ d|_ |rt|ts|d|_|d|_n||_d|_|jr;tj|jstd |j|jr=tj|jstd |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. httpsNTzCCould not find a suitable TLS CA certificate bundle, invalid path: CERT_REQUIRED CERT_NONErrz7Could not find the TLS certificate file, invalid path: z/Could not find the TLS key file, invalid path: )rxryr#r"ospathexistsOSError cert_reqsisdirca_certs ca_cert_dir isinstancer cert_filekey_file)r6connurlr>r?cert_locs r- cert_verifyzHTTPAdapter.cert_verifys 99;; ! !' * * $v $HT!!! H/0FGG 27>>(#;#; 0%-00 -DN7==** , ( #+  (DN DM#D   dJ// %!%a $Q !% $ ~ bgnnT^&D&D 6%)^66} RW^^DM%B%B UdmUU      r.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 statusNheaderszutf-8)r r` status_coder!rr%encodingrawreasonrrbytesdecodercookiesr; connection)r6reqrespresponses r-build_responsezHTTPAdapter.build_response&s:: '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.) r'r&rhostrr}connection_from_urlrgeturlrp)r6rr@rz proxy_urlrYrparseds r-get_connectionzHTTPAdapter.get_connectionKsS'**  =,UF;;E!%((I> %5!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 rFrt)r'rrschemerxrypath_urlr() r6r;r@rzris_proxied_http_requestusing_socks_proxy proxy_schemers r- request_urlzHTTPAdapter.request_urlrsW['22'+&&-"'"=Fg,=!  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(). Nro)r6r;r,s r- add_headerszHTTPAdapter.add_headerss  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)r$r)r6rzrrurvs r-rwzHTTPAdapter.proxy_headerss>.u55(  Q-f$rx}t|t8rt;||t|t@rtC||t|tDrtG||d}~wwxYw|$|| S) aSends 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 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)connectrTzInvalid timeout za. Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same value.F) methodrbodyrredirectassert_same_hostpreload_contentdecode_contentretriesr=chunked)%rrrrrrrrrrtuple TimeoutSauce ValueErrorurlopenrrNr rrrrrr rr r _ProxyErrorr _SSLErrorrr _HTTPErrorr r_InvalidHeaderrr)r6r;r<r=r>r?r@rerrrrTrerrs r-rAzHTTPAdapter.sends& 1&&w{G<??=(G<<<<!(M22 5 G4444!(K00 5 G4444!(I.. 3q'2222!!W555 5 6 6 6!!W555 5   Q-- :&   !Y'' q'2222A/00 !!W5555A~.. #Aw7777 ""7D111sf >9>8CC-4ELE00 L=CI L!I22 L?JL"A3LLr3rE)rFrGrHrIrdDEFAULT_POOLSIZErWDEFAULT_POOLBLOCKr5rerkrZr}rrrrDrrrwrArJrKs@r-rMrMdsI4I*%#$ PPPPPP,LLL    +<    4$$$L777r###J::    ,TXh2h2h2h2h2h2h2h2r.rM)BrIos.pathrsocketurllib3.exceptionsrrrrrrrrr r r rr r rrurllib3.poolmanagerrr urllib3.utilrrrurllib3.util.retryrauthrcompatrrrr exceptionsrrrrrrrmodelsr structuresr!utilsr"r#r$r%r&r'r(urllib3.contrib.socksr) ImportErrorrrrWDEFAULT_POOL_TIMEOUTr1rMror.r-rs2 CCCCCCCC666666>>>>>> 988888>>>>>>>>444444;;;;;;;;000000""""""$$$$$$!!!!!!((((((((++++++                        ++++++G7777777GGGGGGGGG """"""""