o
    ­—Žjº  ã                   @  sÈ   d dl mZ d dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZ d dlmZ erZd dlmZmZ d d	lmZ d d
lmZ d dlmZ d dlmZ G dd„ deƒZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚ
CollectionÚMapping)ÚHTTPAdapter)Ú	DictCache)ÚPERMANENT_REDIRECT_STATUSESÚCacheController)ÚCallbackFileWrapper)ÚPreparedRequestÚResponse)ÚHTTPResponse)Ú	BaseCache)ÚBaseHeuristic)Ú
Serializerc                      sr   e Zd Zh d£Z						d-d.‡ fdd„Z						d/d0‡ fd$d%„Z		d1d2‡ fd)d*„Zd3‡ fd+d,„Z‡  ZS )4ÚCacheControlAdapter>   ÚPUTÚPATCHÚDELETENTÚcacheúBaseCache | NoneÚcache_etagsÚboolÚcontroller_classútype[CacheController] | NoneÚ
serializerúSerializer | NoneÚ	heuristicúBaseHeuristic | NoneÚcacheable_methodsúCollection[str] | NoneÚargsr   ÚkwÚreturnÚNonec           
        sT   t ƒ j|i |¤Ž |d u rtƒ n|| _|| _|pd| _|pt}	|	| j||d�| _d S )N)ÚGET)r   r   )ÚsuperÚ__init__r   r   r   r    r
   Ú
controller)
Úselfr   r   r   r   r   r    r"   r#   Úcontroller_factory©Ú	__class__© ú]/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.pyr(      s   
ÿzCacheControlAdapter.__init__FÚrequestr   ÚstreamÚtimeoutú7None | float | tuple[float, float] | tuple[float, None]Úverifyú
bool | strÚcertú4None | bytes | str | tuple[bytes | str, bytes | str]ÚproxiesúMapping[str, str] | Noner   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
ƒ  ||||||¡}
|
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'   Úsend)r*   r0   r1   r2   r4   r6   r8   r    Ú	cacheableÚcached_responseÚrespr,   r.   r/   rC   2   s   

ÿzCacheControlAdapter.sendÚresponser   r:   c           
   	     s*  |p| j }|sl|j|v rl| jr| j |¡}|jdkr4| j ||¡}||ur'd}|jdd� | ¡  |}n8t	|jƒt
v rC| j ||¡ n)t|jt | jj|t |¡¡ƒ|_|jrl|jj‰ d‡ fd	d
„}t |t |¡¡|_tƒ  ||¡}|j| jv r�|jr�|jdusƒJ ‚| 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_contentÚ	weak_selfú#weakref.ReferenceType[HTTPResponse]r$   r%   c                   s6   | ƒ }|d u r	d S ˆ |ƒ |j dkr|j ¡  d S d S )Nr   )Ú
chunk_leftÚ_fpÚ_close)rI   r*   ©Úsuper_update_chunk_lengthr.   r/   Ú_update_chunk_length‰   s   
ÿz@CacheControlAdapter.build_response.<locals>._update_chunk_lengthN)rI   rJ   r$   r%   )r    r;   r   ÚapplyÚstatusr)   Úupdate_cached_responseÚreadÚrelease_connÚintr	   Úcache_responser   rL   Ú	functoolsÚpartialÚweakrefÚrefÚchunkedr-   rP   r'   r?   Úinvalidating_methodsÚokÚurlÚ	cache_urlr   Údeleter:   )
r*   r0   rG   r:   r    rD   rE   rP   rF   r`   r,   rN   r/   r?   P   sD   

ÿÿþ
ÿz"CacheControlAdapter.build_responsec                   s   | j  ¡  tƒ  ¡  d S )N)r   Úcloser'   )r*   r,   r.   r/   rb   ¥   s   
zCacheControlAdapter.close)NTNNNN)r   r   r   r   r   r   r   r   r   r   r    r!   r"   r   r#   r   r$   r%   )FNTNNN)r0   r   r1   r   r2   r3   r4   r5   r6   r7   r8   r9   r    r!   r$   r   )FN)
r0   r   rG   r   r:   r   r    r!   r$   r   )r$   r%   )	Ú__name__Ú
__module__Ú__qualname__r]   r(   rC   r?   rb   Ú__classcell__r.   r.   r,   r/   r      s(    ùø"ûUr   )Ú
__future__r   rX   rZ   r=   Útypingr   r   r   r   Úpip._vendor.requests.adaptersr   Úpip._vendor.cachecontrol.cacher   Ú#pip._vendor.cachecontrol.controllerr	   r
   Ú$pip._vendor.cachecontrol.filewrapperr   Úpip._vendor.requestsr   r   Úpip._vendor.urllib3r   r   Ú#pip._vendor.cachecontrol.heuristicsr   Ú"pip._vendor.cachecontrol.serializer   r   r.   r.   r.   r/   Ú<module>   s    