o
    Ëý°j©  ã                   @   s`   d dl Z d dlZd dlZd dlmZ ddlmZmZ ddlm	Z	 ddl
mZ G dd„ deƒZdS )	é    N)ÚHTTPAdapteré   )ÚCacheControllerÚPERMANENT_REDIRECT_STATUSES)Ú	DictCache)ÚCallbackFileWrapperc                       s\   e Zd Zh d£Z						d‡ fdd„	Zd‡ fdd„	Z	d‡ fd	d
„	Z‡ fdd„Z‡  ZS )ÚCacheControlAdapter>   ÚPUTÚPATCHÚDELETENTc           
         sX   t t| ƒj|i |¤Ž |d u rtƒ n|| _|| _|pd| _|p t}	|	| j||d�| _d S )N)ÚGET)Úcache_etagsÚ
serializer)	Úsuperr   Ú__init__r   ÚcacheÚ	heuristicÚcacheable_methodsr   Ú
controller)
Úselfr   r   Úcontroller_classr   r   r   ÚargsÚkwÚcontroller_factory©Ú	__class__© ú“/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.pyr      s   
ÿzCacheControlAdapter.__init__c                    s‚   |p| j }|j|v r3z| j |¡}W n tjy   d}Y nw |r)| j||dd�S |j | j 	|¡¡ t
t| ƒj|fi |¤Ž}|S )z”
        Send a request. Use the request information to see if it
        exists in the cache and cache the response if we need to and can.
        NT)Ú
from_cache)r   Úmethodr   Úcached_requestÚzlibÚerrorÚbuild_responseÚheadersÚupdateÚconditional_headersr   r   Úsend)r   Úrequestr   r   Ú	cacheableÚcached_responseÚrespr   r   r   r'   (   s   

ÿzCacheControlAdapter.sendFc           
         s  |p| j }|sd|j|v rd| jr| j |¡}|jdkr4| j ||¡}||ur'd}|jdd� | ¡  |}n0t	|jƒt
v rC| j ||¡ n!t|jt | jj||¡ƒ|_|jrd|j‰ ‡ fdd„}t ||¡|_tt| ƒ ||¡}|j| jv rƒ|jrƒ| j |j¡}	| j |	¡ ||_|S )z¥
        Build a response by making a request or using the cache.

        This will end up calling send and returning a potentially
        cached response
        i0  TF)Údecode_contentc                    s"   ˆ ƒ  | j dkr| j ¡  d S d S )Nr   )Ú
chunk_leftÚ_fpÚ_close©r   ©Úsuper_update_chunk_lengthr   r   Ú_update_chunk_lengthr   s   
ÿz@CacheControlAdapter.build_response.<locals>._update_chunk_length)r   r   r   ÚapplyÚstatusr   Úupdate_cached_responseÚreadÚrelease_connÚintr   Úcache_responser   r.   Ú	functoolsÚpartialÚchunkedr3   ÚtypesÚ
MethodTyper   r   r#   Úinvalidating_methodsÚokÚ	cache_urlÚurlr   Údeleter   )
r   r(   Úresponser   r   r)   r*   r3   r+   rB   r   r1   r   r#   =   sB   
	
ÿ
ÿþÿz"CacheControlAdapter.build_responsec                    s   | j  ¡  tt| ƒ ¡  d S ©N)r   Úcloser   r   r0   r   r   r   rG   ‡   s   
zCacheControlAdapter.close)NTNNNNrF   )FN)	Ú__name__Ú
__module__Ú__qualname__r@   r   r'   r#   rG   Ú__classcell__r   r   r   r   r      s    ùÿJr   )r>   r;   r!   Úpip._vendor.requests.adaptersr   r   r   r   r   r   Úfilewrapperr   r   r   r   r   r   Ú<module>   s   