id @dZddlZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z ejeZejdZd Zd ZGd d eZdS) z7 The httplib2 algorithms ported for use with requests. N) parsedate_tz)CaseInsensitiveDict) DictCacheSeparateBodyBaseCache) Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)-4ct|}|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) r)URImatchgroups)urirs X/opt/cloudlinux/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/controller.py parse_urirsD YYs^^ " " $ $F 1Ivay&)VAYq BBcpeZdZdZ d dZedZedZdZdZ d Z dd Z dd Z d Z dS)CacheControllerz4An interface to see if request should cached or not.NTc~|tn||_||_|p t|_|pd|_dS)N)i,r r )rcache cache_etagsr serializercacheable_status_codes)selfrrr status_codess r__init__zCacheController.__init__'sC%*MY[[[u &$4 &2&O6O###rct|\}}}}}|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/+= rc,||SN)r1)r)rs r cache_urlzCacheController.cache_urlCs||C   rc 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__) r headersknown_directives cc_headersretval cc_directiveparts directivetyprequireds rparse_cache_controlz#CacheController.parse_cache_controlGsT{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 *E76E7cv||j}td|||j}d|vrtddSd|vr(|ddkrtddS|j|}|td dSt|jtr|j |}nd}|j |||}|st d dSt|jt vrd }t||St#|j}|rd |vrTd |vr4td|j|tddSt'j} t)jt-|d } t/d| | z } td| ||} d} d| vr$| d} td| n]d|vrYt-|d}|Bt)j|| z }t/d|} td| d|vr#|d} td| d|vr(|d}| |z } td| | | kr8tdtd| | |Sd |vr4td|j|dS)ze Return a cached response if it exists in the cache, otherwise return False. zLooking up "%s" in the cacher8z-Request header has "no-cache", cache bypassedFr6rz1Request header has "max_age" as 0, cache bypassedNzNo cache entry availablez1Cache entry deserialization failed, entry ignoredzQReturning cached permanent redirect response (ignoring date and etag information)dateetagz(Purging cached response: no date or etagz!Ignoring cached response: no datezCurrent age based on date: %iz#Freshness lifetime from max-age: %iexpiresz#Freshness lifetime from expires: %iz+Freshness lifetime from request max-age: %ir7z'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)r4urlrDrErRrIrr@ isinstancerget_bodyrloadswarningr?statusPERMANENT_REDIRECT_STATUSESrdeletetimecalendartimegmrmax)r requestr4cc cache_data body_filerespmsgrInowrT current_ageresp_ccfreshness_lifetimerV expire_time min_freshs rcached_requestzCacheController.cached_request}s NN7;//  3Y???  % %go 6 6    LLH I I I5 ??r)}11 LLL M M M5Z^^I..   LL3 4 4 45 dj"7 8 8  ++I66III$$Wj)DD  NNN O O O5 t{  : : :7  LL   K%dl33 &//W$$ GHHH !!),,, LL< = = =5ikk|GFO<<==!S4Z((  4kBBB **733   !(!3  LL>@R S S S S' ! !"79#566G"&og66= %(K%8%8" BDVWWW ??!#I  LL=?Q    "  ;I 9 $K LLBK P P P  + + LLM N N N LL$6 D D DK  LLO P P P J  i ( ( (urc ||j}|j||j|}i}|r2t |j}d|vr |d|d<d|vr |d|d<|S)NrUETagz If-None-Matchz last-modifiedz Last-ModifiedzIf-Modified-Since)r4rWrrZrr@rrI)r rcr4rg new_headersrIs rconditional_headersz#CacheController.conditional_headerssNN7;// $$WdjnnY.G.GHH  L)$,77G  /6v O,'))3:?3K /0rcPt|jtrT|j||j||d||j||dS|j||j||||dS)z. Store the data in the cache. r)rVN)rXrrsetrdumpsset_body)r r4rcresponsebody expires_times r _cache_setzCacheController._cache_sets dj"7 8 8  JNN%%gx==$     J   4 0 0 0 0 0 JNN%%gx>>$      rc|p|j}|j|vr#td|j|dSt |j}d|vr(t jt|d}nd}|Fd|vrB|d r(t|dt|krdS| |j}| |} | |j} td| d} d| vrd } td d|vrd } td | rN|j| r4td |j| | rdSd |ddvrtddS|jrd|vrd} |dr.t|d} | t j| |z } t'| d} td| td|| |||| dSt|jt,vr4td|| ||ddSd|vrt jt|d}d| vrI| ddkr=td| d} || |||| dSd|vr|dr}t|d} | t j| |z } nd} td| || |||| dSdSdSdS)zc Algorithm for caching requests. This assumes a requests Response object. zStatus code %s not in %sNrTrcontent-lengthz&Updating cache with response from "%s"Fr9TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"*varyr<zResponse header has "Vary: *"rUrViuz"etag object cached for {0} secondszCaching due to etagzCaching permanent redirectrr6z'Caching b/c date exists and max-age > 0z5Caching b/c of expires header. expires in {0} seconds)rr\rDrErrIr`rarisdigitr?lenrRr4rWrr@r^rrbformatr{r])r rcrxryr!rresponse_headersrTcc_reqrdr4no_storerzrVs rcache_responsezCacheController.cache_responsesb".!L1L ?"8 8 8 LL*HO=S    F.x/?@@ % % %?<0@0H#I#IJJDDD   $444 !12::<<5$%56773t99DD F))'/::  % %&6 7 7NN7;//  =yIII   H LL9 : : :   H LL8 9 9 9  ) y11 ) LLK L L L J  i ( ( (   F "&&vr22 2 2 LL8 9 9 9 F  9 *: : :L##I.. C&'7 'BCC&#+?7#;#;d#BL|Z88L LL=DD\RR S S S LL. / / / OOIw$ M M M M M ! !%@ @ @ LL5 6 6 6 OOIw# > > > > > ' ' '?<0@0H#I#IJJDB2i=1#4#4 FGGG!)}  ...#I.*+;I+FGGG*'/w'?'?$'F '+ LLOVV( OO! $ ;( ' /.rc||j}|j||j|}|s|Sdg|jtfd|j Dd|_ | ||||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. r}c3RK|]!\}}|v||fV"dSr3)r').0kvexcluded_headerss r z9CacheController.update_cached_response..sKAq7799$444A4444rr) r4rWrrZrr@rIupdatedictitemsr\r{)r rcrxr4cached_responsers @rupdate_cached_responsez&CacheController.update_cached_responsesNN7;// /// 9R9RSS O--&& $,2244     "%  7O<<<r)NTNN)NN)rH __module__ __qualname____doc__r" classmethodr1r4rRrorsr{rrrrrr$s>>KOPPPP[&!![!444lsssj (yyyyv&&&&&rr)rloggingrer`r_ email.utilsrpip._vendor.requests.structuresrrrr serializer getLoggerrHrDcompilerr]robjectrrrrrs   $$$$$$??????33333333!!!!!!  8 $ $bjMNN(CCCSSSSSfSSSSSr