<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    ÀÒ.e‚5  ã                   @   s„   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ e e¡Ze d¡Zd	d
„ ZG dd„ deƒZdS )z7
The httplib2 algorithms ported for use with requests.
é    N)Úparsedate_tz)ÚCaseInsensitiveDicté   )Ú	DictCache)Ú
Serializerz9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?c                 C   s0   t  | ¡ ¡ }|d |d |d |d |d fS )z‡Parses a URI using the regex given in Appendix B of RFC 3986.

        (scheme, authority, path, query, fragment) = parse_uri(uri)
    r   é   é   é   é   )ÚURIÚmatchÚgroups)Úurir   © r   úG/usr/lib/python3.8/site-packages/pip/_vendor/cachecontrol/controller.pyÚ	parse_uri   s    r   c                   @   s\   e Zd ZdZddd„Zedd„ ƒZedd	„ ƒZd
d„ Zdd„ Z	dd„ Z
ddd„Zdd„ ZdS )ÚCacheControllerz9An interface to see if request should cached or not.
    NTc                 C   s,   |pt ƒ | _|| _|ptƒ | _|p$d| _d S )N)éÈ   éË   i,  é-  )r   ÚcacheÚcache_etagsr   Ú
serializerÚcacheable_status_codes)Úselfr   r   r   Ústatus_codesr   r   r   Ú__init__"   s    zCacheController.__init__c           	      C   sh   t |ƒ\}}}}}|r|s&td| ƒ‚| ¡ }| ¡ }|s>d}|rPd ||g¡pR|}|d | | }|S )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %sú/ú?z://)r   Ú	ExceptionÚlowerÚjoin)	Úclsr   ZschemeZ	authorityÚpathZqueryZfragmentZrequest_uriZ
defrag_urir   r   r   Ú_urlnorm*   s    zCacheController._urlnormc                 C   s
   |   |¡S ©N)r$   )r"   r   r   r   r   Ú	cache_url>   s    zCacheController.cache_urlc           
      C   s(  t dft dft dfddddddddt dfdœ}| d| dd¡¡}i }| d¡D ]Ò}| ¡ s^qP| d	d
¡}|d  ¡ }z|| \}}	W n$ tk
rª   t d|¡ Y qPY nX |r´|	s¼d ||< |rPz||d
  ¡ ƒ||< W qP tk
rü   |	røt d|¡ Y qP tk
r    t d||j	¡ Y qPX qP|S )NTF)NF)úmax-agez	max-staleú	min-freshúno-cacheúno-storezno-transformzonly-if-cachedzmust-revalidateZpublicZprivatezproxy-revalidatezs-maxagezcache-controlzCache-ControlÚ ú,ú=r   r   z,Ignoring unknown cache-control directive: %sz-Missing value for cache-control directive: %sz8Invalid value for cache-control directive %s, must be %s)
ÚintÚgetÚsplitÚstripÚKeyErrorÚloggerÚdebugÚ
IndexErrorÚ
ValueErrorÚ__name__)
r   ÚheadersZknown_directivesZ
cc_headersZretvalZcc_directiveÚpartsZ	directiveÚtypZrequiredr   r   r   Úparse_cache_controlB   sV    ó
þýz#CacheController.parse_cache_controlc                 C   s0  |   |j¡}t d|¡ |  |j¡}d|kr:t d¡ dS d|kr\|d dkr\t d¡ dS | j |¡}|dkr~t d	¡ dS | j 	||¡}|sžt 
d
¡ dS |jdkrºd}t |¡ |S t|jƒ}|rÐd|krüd|krît d¡ | j |¡ t d¡ dS t ¡ }t t|d ƒ¡}	td||	 ƒ}
t d|
¡ |  |¡}d}d|kr^|d }t d|¡ nDd|kr¢t|d ƒ}|dk	r¢t |¡|	 }td|ƒ}t d|¡ d|krÀ|d }t d|¡ d|kræ|d }|
|7 }
t d|
¡ ||
krt d¡ t d||
¡ |S d|kr,t d¡ | j |¡ dS )ze
        Return a cached response if it exists in the cache, otherwise
        return False.
        zLooking up "%s" in the cacher)   z-Request header has "no-cache", cache bypassedFr'   r   z1Request header has "max_age" as 0, cache bypassedNzNo cache entry availablez1Cache entry deserialization failed, entry ignoredr   zVReturning cached "301 Moved Permanently" response (ignoring date and etag information)ÚdateÚetagz(Purging cached response: no date or etagz!Ignoring cached response: no datezCurrent age based on date: %iz#Freshness lifetime from max-age: %iÚexpiresz#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&   Úurlr3   r4   r;   r8   r   r/   r   ÚloadsZwarningÚstatusr   ÚdeleteÚtimeÚcalendarZtimegmr   Úmax)r   Úrequestr&   ÚccZ
cache_dataÚrespÚmsgr8   Znowr<   Zcurrent_ageZresp_ccZfreshness_lifetimer>   Zexpire_timeZ	min_freshr   r   r   Úcached_requestx   s|    





ÿ









 ÿ




zCacheController.cached_requestc                 C   s`   |   |j¡}| j || j |¡¡}i }|r\t|jƒ}d|krH|d |d< d|kr\|d |d< |S )Nr=   ZETagzIf-None-Matchzlast-modifiedzLast-ModifiedzIf-Modified-Since)r&   r?   r   r@   r   r/   r   r8   )r   rF   r&   rH   Znew_headersr8   r   r   r   Úconditional_headersç   s    
z#CacheController.conditional_headersc                 C   sä  |p| j }|j|kr(t d|j|¡ dS t|jƒ}|dk	rfd|krf|d  ¡ rft|d ƒt|ƒkrfdS |  	|j¡}|  	|¡}|  
|j¡}	t d|	¡ d}
d|kr®d}
t d¡ d|krÄd}
t d	¡ |
rê| j |	¡rêt d
¡ | j |	¡ |
ròdS | jr,d|kr,t d¡ | j |	| jj|||d¡ n´|jdkr\t d¡ | j |	| j ||¡¡ n„d|kràd|kr¦|d dkr¦t d¡ | j |	| jj|||d¡ n:d|krà|d ràt d¡ | j |	| jj|||d¡ dS )zc
        Algorithm for caching requests.

        This assumes a requests Response object.
        zStatus code %s not in %sNúcontent-lengthz&Updating cache with response from "%s"Fr*   TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"r=   zCaching due to etag)Úbodyr   zCaching permanant redirectr<   r'   r   z'Caching b/c date exists and max-age > 0r>   zCaching b/c of expires header)r   rA   r3   r4   r   r8   Úisdigitr.   Úlenr;   r&   r?   r   r/   rB   r   Úsetr   Údumps)r   rF   ÚresponserM   r   r   Zresponse_headersZcc_reqrG   r&   Zno_storer   r   r   Úcache_response÷   sr    

  ÿ
ÿþ
ýü




 ÿ


 ÿ


 ÿzCacheController.cache_responsec                    sv   |   |j¡}| j || j |¡¡}|s*|S dg‰ |j t‡ fdd„|j 	¡ D ƒƒ¡ d|_
| j || j ||¡¡ |S )zéOn 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.
        rL   c                 3   s&   | ]\}}|  ¡ ˆ kr||fV  qd S r%   )r    )Ú.0ÚkÚv©Zexcluded_headersr   r   Ú	<genexpr>b  s   þz9CacheController.update_cached_response.<locals>.<genexpr>r   )r&   r?   r   r@   r   r/   r8   ÚupdateÚdictÚitemsrA   rP   rQ   )r   rF   rR   r&   Zcached_responser   rW   r   Úupdate_cached_responseI  s    	þÿ	z&CacheController.update_cached_response)NTNN)NN)r7   Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr$   r&   r;   rJ   rK   rS   r\   r   r   r   r   r      s          ÿ


6o
Rr   )r_   ZloggingÚrerD   rC   Zemail.utilsr   Zpip._vendor.requests.structuresr   r   r   Z	serializer   Z	getLoggerr7   r3   Úcompiler   r   Úobjectr   r   r   r   r   Ú<module>   s   

	