\hGdZddlmZddlZddlZddlZddlZddlmZddl m Z m Z m Z ddl mZddlmZmZddlmZe rdd l mZdd lmZdd lmZdd lmZej4eZej:d ZdZddZ GddZ!y)z7 The httplib2 algorithms ported for use with requests. ) annotationsN) parsedate_tz) TYPE_CHECKING CollectionMapping)CaseInsensitiveDict) DictCacheSeparateBodyBaseCache) Serializer)Literal)PreparedRequest) HTTPResponse) BaseCachez9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)-4ctj|}|J|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) )URImatchgroups)urirrs f/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/cachecontrol/controller.py parse_urir%sM IIcNE    \\^F 1Ivay&)VAYq BBceZdZdZ d ddZeddZeddZddZddZ ddZ dd Z d dd Z d dd Z dd Zy)CacheControllerz4An interface to see if request should cached or not.Nct| tn||_||_|xs t|_|xsd|_y)N)i,rr)r cache cache_etagsr serializercacheable_status_codes)selfr$r%r& status_codess r__init__zCacheController.__init__3s7%*MY[u &$4 &2&O6O#rct|\}}}}}|r|std|z|j}|j}|sd}|xrdj||gxs|}|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%YFLM MOO% D7$ 7?4 e^i/+= rc$|j|S)N)r9)r1rs r cache_urlzCacheController.cache_urlSs||C  rc tdftdftdfddddddddtdfd }|jd|jdd}i}|jdD]j}|js|jd d }|d j} ||\}} |r| sd||<|sN ||d j||<l|S#t$rt j d |YwxYw#t$r| rt j d |Yt$r$t j d||jYwxYw)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_controlWsfT{ut%%)+,#$ -d   [['++or2RS (*&,,S1 L%%' &&sA.Ea(I  0 ; X h$(y! (+E!HNN,<(=F9%# > -  KYW " N%"LLU! s*C ,C1 C.-C.1!E)E?Ecd|j}|J|jj|}|tj dyt |jt r|jj|}nd}|jj|||}|tjd|S)zO Load a cached response, or return None if it's not available. NzNo cache entry availablez1Cache entry deserialization failed, entry ignored) urlr$rGrKrL isinstancer get_bodyr&loadswarning)r(requestr; cache_data body_fileresults r_load_from_cachez CacheController._load_from_cachesKK $$$ZZ^^I.   LL3 4 djj"7 8 ++I6II&&w IF > NNN O rc|jJ|j|j}tjd||j |j }d|vrtjdyd|vr|ddk(rtjdy|j |}|syt|jtvrd }tj||St|j }|rd |vrJd |vr0tjd |jj|tjd ytj}t|d }|Jtj |dd} t#d|| z } tjd| |j |} d} | j%d} | | } tjd| nQd|vrMt|d}|=tj |dd| z }t#d|} tjd| |j%d} | | } tjd| |j%d}|| |z } tjd| | | kDr.tjdtjd| | |Sd |vr0tjd|jj|y)ze Return a cached response if it exists in the cache, otherwise return False. NzLooking up "%s" in the cacher?z-Request header has "no-cache", cache bypassedFr=rz1Request 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: %ir>z'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)r[r;rKrLrYrPrdrFstatusPERMANENT_REDIRECT_STATUSESrr$deletetimercalendartimegmmaxrG)r(r`r;ccrespmsgrPnow time_tuplerf current_ageresp_ccfreshness_lifetimemax_agerh expire_time min_freshs rcached_requestzCacheController.cached_requests {{&&&NN7;;/  3Y?  % %goo 6   LLH I ?r)}1 LLL M$$W- t{{ : :7  LL K,? ,M&/W$ GH !!), LL< =iik!'&/2 %%%z"1~.!S4Z(  4kB **73++i(  !(  LL>@R S' !"79#56G"&oogbqk:TA %(K%8" BDVW&&#  !(  LL=?Q FF;'  9 $K LLBK P  + LLM N LL$6 DK  LLO P JJ  i (rc|j|}i}|r-t|j}d|vr|d|d<d|vr|d|d<|S)NrgETagz If-None-Matchz last-modifiedz Last-ModifiedzIf-Modified-Since)rdrrP)r(r`rq new_headersrPs rconditional_headersz#CacheController.conditional_headerss\$$W- 0CDLL0QG /6v O,')3:?3K /0rc\t|jtrY|jj||jj ||d|||jj ||yy|jj||jj ||||y)z. Store the data in the cache. r)rhN)r\r$r setr&dumpsset_body)r(r;r`responsebody expires_times r _cache_setzCacheController._cache_sets djj"7 8 JJNN%%gx=$   ##It4  JJNN%%gx>$  rcD|xs |j}|j|vr"tjd|j|yt |j }d|vr+t |d}|Jtj|dd}nd}|2d|vr.|djrt|dt|k7ry|j|j } |j|} |jJ|j|j} tjd| d} d | vrd } tjd d | vrd } tjd | rK|jj!| r0tjd |jj#| | ryd|j!ddvrtjdy|j$rd|vrd} |j!dr+t |d}|tj|dd|z } t'| d} tjd| dtjd|j)| |||| yt|jt*vr*tjd|j)| ||dyd|vrt |d}|Jtj|dd}| j!d}|2|dkDr-tjd|} |j)| |||| yd|vrn|drht |d}|tj|dd|z } nd} tjdj-| |j)| |||| yyyy)zc Algorithm for caching requests. This assumes a requests Response object. zStatus code %s not in %sNrfrrcontent-lengthz&Updating cache with response from "%s"Fr@TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"*varyrCzResponse header has "Vary: *"rgrhiuzetag object cached for z secondszCaching due to etagzCaching permanent redirectrr=z'Caching b/c date exists and max-age > 0z4Caching b/c of expires header. expires in {} seconds)r'rirKrLrrPrrmrnisdigitrFlenrYr[r;r$rGrkr%rorrjformat)r(r`rrr)r'response_headersrtrfcc_reqrpr;no_storerrhrxs rcache_responsezCacheController.cache_response=s".!L1L1L ??"8 8 LL*HOO=S  5H   6  % %%&6v&>?J) ))??:bq>2DD   $44 !12::<$%5673t9D ))'//:  % %&6 7{{&&&NN7;;/  =yI  H LL9 :  H LL8 9  y1 LLK L JJ  i (   "&&vr2 2 LL8 9    *: :L##I.&'7 'BC&#+??72A;#?$#FL|Z8L LL2<.I J LL. / OOIw$ M !%@ @ LL5 6 OOIw# > ' '%&6v&>?J) ))??:bq>2DffY'G"w{ FG&  ..#I.*+;I+FGG*'/wr{'Cd'J '+ LLNUU( OO! $ //'(rcz|jJ|j|j}|j|}|s|Sdg}|jj |jj Dcic]\}}|j |vr||c}}d|_|j||||Scc}}w)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. rr") r[r;rdrPupdateitemsr/rir)r(r`rr;cached_responseexcluded_headerskvs rupdate_cached_responsez&CacheController.update_cached_responses{{&&&NN7;;/ //8O--&&%,,224 Aq779$441  "%  7O< s4B7 )NTNN)r$zBaseCache | Noner%boolr&zSerializer | Noner)Collection[int] | None)rstrreturnr)rPzMapping[str, str]rzdict[str, int | None])r`r rzHTTPResponse | None)r`r rzHTTPResponse | Literal[False])r`r rzdict[str, str])NN) r;rr`r rrr bytes | Nonerz int | NonerNone) r`r rrrrr)rrr)r`r rrrr)rO __module__ __qualname____doc__r* classmethodr9r;rYrdr{rrrrrrr r 0s+>#' (,/3 P P P& P - P&!!4l*l\ ("#' !    !  D"/3 G GG G - G  GR(&(2>( (rr )rrrztuple[str, str, str, str, str])"r __future__rrmloggingrerl email.utilsrtypingrrrpip._vendor.requests.structuresrpip._vendor.cachecontrol.cacher r "pip._vendor.cachecontrol.serializer r pip._vendor.requestsr pip._vendor.urllib3rr getLoggerrOrKcompilerrjrr rrrrsw # $55?K9408   8 $bjjMN(C~~r