ReE7dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ej eZejdZd ZGd d eZdS) z7 The httplib2 algorithms ported for use with requests. N) parsedate_tz)CaseInsensitiveDict) DictCache) Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?ct|}|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 /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/cachecontrol/controller.py parse_urirsD YYs^^ " " $ $F 1Ivay&)VAYq BBcheZdZdZ d dZedZedZdZdZ d Z d d Z d Z dS)CacheControllerz9An interface to see if request should cached or not. NTc~|tn||_||_|p t|_|pd|_dS)N)i,-)rcache cache_etagsr serializercacheable_status_codes)selfrrr status_codess r__init__zCacheController.__init__"sC%*MY[[[u &$4 &2&J6J###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)r/)r'rs r cache_urlzCacheController.cache_url>s||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__) rheadersknown_directives cc_headersretval cc_directiveparts directivetyprequireds rparse_cache_controlz#CacheController.parse_cache_controlBsT{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 *E76E7c||j}td|||j}d|vrtddSd|vr(|ddkrtddS|j|}|td dS|j ||}|st d dS|j d krd }t||St|j}|rd |vrTd|vr4td|j |tddStj}tjt#|d } t%d|| z } td| ||} d} d| vr$| d} td| n]d|vrYt#|d} | Btj| | 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 cacher6z-Request header has "no-cache", cache bypassedFr4rz1Request header has "max_age" as 0, cache bypassedNzNo cache entry availablez1Cache entry deserialization failed, entry ignoredrzVReturning cached "301 Moved Permanently" 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: %ir5z'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)r2urlrBrCrPrGrr>rloadswarningstatusrdeletetimecalendartimegmrmax)rrequestr2cc cache_datarespmsgrGnowrR current_ageresp_ccfreshness_lifetimerT expire_time min_freshs rcached_requestzCacheController.cached_requestxs| NN7;//  3Y???  % %go 6 6    LLH I I I5 ??r)}11 LLL M M M5Z^^I..   LL3 4 4 45$$Wj99  NNN O O O5 ;#  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)NrSETagz If-None-Matchz last-modifiedz Last-ModifiedzIf-Modified-Since)r2rUrrVrr>rrG)rr^r2ra new_headersrGs rconditional_headersz#CacheController.conditional_headerssNN7;// $$WdjnnY.G.GHH  L)$,77G  /6v O,'))3:?3K /0rc|p|j}|j|vr#td|j|dSt |j}|Fd|vrB|dr(t|dt|krdS| |j}| |}| |j } td| d} d|vrd} tdd|vrd} td | rN|j | r4td |j | | rdSd | d d vrtddS|jrVd|vrRtd|j | |j|||dS|jdkrPtd|j | |j||dSd|vrd|vr^|ddkrRtd|j | |j|||dSd|vr\|drVtd|j | |j|||dSdSdSdS)zc Algorithm for caching requests. This assumes a requests Response object. zStatus code %s not in %sNcontent-lengthz&Updating cache with response from "%s"Fr7TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"*varyr:zResponse header has "Vary: *"rSzCaching due to etag)bodyrzCaching permanant redirectrRr4rz'Caching b/c date exists and max-age > 0rTzCaching b/c of expires header)rrXrBrCrrGisdigitr=lenrPr2rUrr>rYrsetrdumps) rr^responserrrrresponse_headerscc_reqr_r2no_stores rcache_responsezCacheController.cache_responses".!L1L ?"8 8 8 LL*HO=S    F.x/?@@   $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   *: : : LL. / / / JNN4?00(0NN      _ # # LL5 6 6 6 JNN9do&;&;GX&N&N O O O O O ' ' 'B2i=1#4#4 FGGG t44WhT4RR ...#I.LL!@AAAJNN!4?#8#8(QU#8#V#V( '/.rc||j}|j||j|}|s|Sdg|jtfd|j Dd|_ |j ||j |||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. roc3RK|]!\}}|v||fV"dSr1)r%).0kvexcluded_headerss r z9CacheController.update_cached_response..ksKAq7799$444A4444rr) r2rUrrVrr>rGupdatedictitemsrXrurv)rr^rwr2cached_responsers @rupdate_cached_responsez&CacheController.update_cached_responseRsNN7;// /// 9R9RSS O--&& $,2244     "% y$/"7"7"Q"QRRRr)NTNN)NN) rF __module__ __qualname____doc__r classmethodr/r2rPrirmr{rrrrrsKOKKKK[&!![!444lmmm^ YYYYv&&&&&rr)rloggingrer[rZ email.utilsrpip._vendor.requests.structuresrrr serializer getLoggerrFrBcompiler robjectrrrrrs  $$$$$$??????!!!!!!  8 $ $bjMNNCCCZZZZZfZZZZZr