hHdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZddlmZmZddlmZe rdd l mZdd lmZdd lmZdd lmZejeZejd ZdZddZ GddZ!dS)z7 The httplib2 algorithms ported for use with requests. ) annotationsN) parsedate_tz) TYPE_CHECKING CollectionMapping)CaseInsensitiveDict) DictCacheSeparateBodyBaseCache) Serializer)Literal)PreparedRequest) HTTPResponse) BaseCachez9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)-4uristrreturntuple[str, str, str, str, str]ct|}|J|}|d|d|d|d|dfS)zParses a URI using the regex given in Appendix B of RFC 3986. (scheme, authority, path, query, fragment) = parse_uri(uri) N)URImatchgroups)rrrs /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/controller.py parse_urir &sQ IIcNNE     \\^^F 1Ivay&)VAYq BBceZdZdZ d)d*d Zed+dZed+dZd,dZd-dZ d.dZ d/dZ d0d1d&Z d0d2d'Z d3d(ZdS)4CacheControllerz4An interface to see if request should cached or not.NTcacheBaseCache | None cache_etagsbool serializerSerializer | None status_codesCollection[int] | Nonec~|tn||_||_|p t|_|pd|_dS)N)i,rr)r r$r&r r(cacheable_status_codes)selfr$r&r(r*s r__init__zCacheController.__init__4sC%*MY[[[u &$4 &2&O6O###r!rrrct|\}}}}}|r|std|z|}|}|sd}|rd||gp|}|dz|z|z}|S)z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %s/?z://)r Exceptionlowerjoin) clsrscheme authoritypathqueryfragment request_uri defrag_uris r_urlnormzCacheController._urlnorm@s6?s^^2D% NY NFLMM MOO%%  D7$ 7 7?4 e^i/+= r!c,||S)N)r@)r8rs r cache_urlzCacheController.cache_urlTs||C   r!headersMapping[str, str]dict[str, int | None]c tdftdftdfddddddddtdfd }|d|dd}i}|dD] }|s|d d }|d } ||\}} n+#t$rt d |Y|wxYw|r| sd||<|r ||d ||<#t$r | rt d |Yt$r%t d||j Y wxYw|S)NTF)NF) max-agez max-stale min-freshno-cacheno-storez no-transformzonly-if-cachedzmust-revalidatepublicprivatezproxy-revalidatezs-maxagez cache-controlz Cache-Control,=rrz,Ignoring unknown cache-control directive: %sz-Missing value for cache-control directive: %sz8Invalid value for cache-control directive %s, must be %s) intgetsplitstripKeyErrorloggerdebug IndexError ValueError__name__) r0rCknown_directives cc_headersretval cc_directiveparts directivetyprequireds rparse_cache_controlz#CacheController.parse_cache_controlXsT{ut%%)+,#$ -d    [['++or2R2RSS (*&,,S11  L%%''  &&sA..Ea((I  0 ; XX    KYWWW  )h )$(y!  (+E!HNN,<,<(=(=F9%%! N%"LLU!    s*6 C%C*)C*9&D  'E7 *E76E7requestr HTTPResponse | Nonecd|jvrdS|j}|J|j|}|tddSt |jtr|j|}nd}|j |||}|t d|S)zO Load a cached response, or return None if it's not available. RangeNzNo cache entry availablez1Cache entry deserialization failed, entry ignored) rCurlr$rQrUrV isinstancer get_bodyr(loadswarning)r0rcrB cache_data body_fileresults r_load_from_cachez CacheController._load_from_caches go % %4K $$$Z^^I..   LL3 4 4 44 dj"7 8 8  ++I66III&&w IFF > NNN O O O r!HTTPResponse | Literal[False]c|jJ||j}td|||j}d|vrtddSd|vr(|ddkrtddS||}|sdSt|jtvrd }t||St|j}|rd |vrTd |vr4td |j |td dStj }t|d }|Jtj|dd} t#d|| z } td| ||} d} | d} | | } td| ned|vrat|d}|Jtj|dd| z }t#d|} td| |d} | | } td| |d}| | |z } td| | | kr8tdtd| | |Sd |vr4td|j |dS)ze Return a cached response if it exists in the cache, otherwise return False. NzLooking up "%s" in the cacherIz-Request header has "no-cache", cache bypassedFrGrz1Request header has "max_age" as 0, cache bypassedzQReturning cached permanent redirect response (ignoring date and etag information)dateetagz(Purging cached response: no date or etagz!Ignoring cached response: no daterzCurrent age based on date: %iz#Freshness lifetime from max-age: %iexpiresz#Freshness lifetime from expires: %iz+Freshness lifetime from request max-age: %irHz'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)rgrBrUrVrbrCrorPstatusPERMANENT_REDIRECT_STATUSESrr$deletetimercalendartimegmmaxrQ)r0rcrBccrespmsgrCnow time_tuplerr current_ageresp_ccfreshness_lifetimemax_agert expire_time min_freshs rcached_requestzCacheController.cached_requests~ {&&&NN7;//  3Y???  % %go 6 6    LLH I I I5 ??r)}11 LLL M M M5$$W-- 5 t{  : : :7  LL   K,? ,M,M &//W$$ GHHH !!),,, LL< = = =5ikk!'&/22 %%%z"1"~..!S4Z((  4kBBB **733++i((  !(  LL>@R S S S S' ! !"79#566G"&ogbqbk::TA %(K%8%8" BDVWWW&&##  !(  LL=?Q   FF;''  9 $K LLBK P P P  + + LLM N N N LL$6 D D DK  LLO P P P J  i ( ( (ur!dict[str, str]c||}i}|r2t|j}d|vr |d|d<d|vr |d|d<|S)NrsETagz If-None-Matchz last-modifiedz Last-ModifiedzIf-Modified-Since)rorrC)r0rcr} new_headersrCs rconditional_headersz#CacheController.conditional_headerssl$$W--  L0CDL0Q0QG  /6v O,'))3:?3K /0r!rBresponserbody bytes | None expires_time int | NoneNonecXt|jtrX|j||j||d|||j||dSdS|j||j||||dS)z. Store the data in the cache. r!)rtN)rhr$r setr(dumpsset_body)r0rBrcrrrs r _cache_setzCacheController._cache_set%s dj"7 8 8  JNN%%gx==$     ##It44444  JNN%%gx>>$      r!c`|p|j}|j|vr#td|j|dSt |j}d|vr6t |d}|Jtj|dd}nd}|Fd|vrB|d r(t|dt|krdS| |j} | |} |j J||j } td| d} d | vrd } td d | vrd } td | rN|j| r4td |j| | rdSd|ddvrtddS|jrd|vrd} |dr6t |d}|tj|dd|z } t'| d} td| dtd|| |||| dSt|jt*vr4td|| ||ddSd|vrt |d}|Jtj|dd}| d}|=|dkr7td|} || |||| dSd|vr|drt |d}| tj|dd|z } nd} td| || |||| dSdSdSdS)zc Algorithm for caching requests. This assumes a requests Response object. zStatus code %s not in %sNrrrrcontent-lengthz&Updating cache with response from "%s"FrJTzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"*varyrMzResponse header has "Vary: *"rsrtiuzetag object cached for z secondszCaching due to etagzCaching permanent redirectr!rGz'Caching b/c date exists and max-age > 0z4Caching b/c of expires header. expires in {} seconds)r/rurUrVrrCrryrzisdigitrPlenrbrgrBr$rQrwr&r{rrvformat)r0rcrrr*r/response_headersrrrcc_reqr|rBno_storerrtrs rcache_responsezCacheController.cache_responseCs".!L1L ?"8 8 8 LL*HO=S    F5H  6 6  % % %%&6v&>??J)))?:bqb>22DDD   $444 !12::<<5$%56773t99DD F))'/::  % %&6 7 7{&&&NN7;//  =yIII   H LL9 : : :   H LL8 9 9 9  ) y11 ) LLK L L L J  i ( ( (   F "&&vr22 2 2 LL8 9 9 9 F  < *: : :L##I.. G&'7 'BCC&#+?72A2;#?#?$#FL|Z88L LLI<III J J J LL. / / / OOIw$ M M M M M ! !%@ @ @ LL5 6 6 6 OOIw# > > > > > ' ' '%&6v&>??J)))?:bqb>22DffY''G"w{{ FGGG&  ...#I.*+;I+FGGG*'/wrr{'C'Cd'J '+ LLNUU( OO! $ A( '&/.r!c<|jJ||j}||}|s|Sdg|jfd|jDd|_|||||S)zOn a 304 we will get a new set of headers that we want to update our cached value with, assuming we have one. This should only ever be called when we've sent an ETag and gotten a 304 as the response. NrcHi|]\}}|v||S)r6).0kvexcluded_headerss r z:CacheController.update_cached_response..s=   Aq7799$4441444r!r-)rgrBrorCupdateitemsrur)r0rcrrBcached_responsers @rupdate_cached_responsez&CacheController.update_cached_responses{&&&NN7;// //88 O--&&    $,2244      "%  7O<<<r!)NTNN)r$r%r&r'r(r)r*r+)rrrr)rCrDrrE)rcr rrd)rcr rrp)rcr rr)NN) rBrrcr rrrrrrrr) rcr rrrrr*r+rr)rcr rrrr)rY __module__ __qualname____doc__r1 classmethodr@rBrbrorrrrrrr!rr#r#1s9>>#' (,/3 P P P P P[&!!![!4444l4llll\    ("#' D"/3 GGGGGR((((((r!r#)rrrr)"r __future__rryloggingrerx email.utilsrtypingrrrpip._vendor.requests.structuresrpip._vendor.cachecontrol.cacher r "pip._vendor.cachecontrol.serializer r pip._vendor.requestsr pip._vendor.urllib3rr getLoggerrYrUcompilerrvr r#rr!rrs #""""" $$$$$$5555555555??????KKKKKKKK9999999444444000000888888  8 $ $bjMNN(CCCCCCCCCCCCCCr!