a
    0f                     @  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rd 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                      s   e Zd Zh dZd dddddd	d
d
dd	 fddZd!ddddddd	dd fddZd"dddd	dd fddZdd fddZ  ZS )#CacheControlAdapter>   PATCHDELETEPUTNTzBaseCache | Noneboolztype[CacheController] | NonezSerializer | NonezBaseHeuristic | NonezCollection[str] | Noner   None)	cachecache_etagscontroller_class
serializer	heuristiccacheable_methodsargskwreturnc           
        sT   t  j|i | |d u r t n|| _|| _|p2d| _|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__ Y/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pip/_vendor/cachecontrol/adapter.pyr#      s    
zCacheControlAdapter.__init__Fr   z7None | float | tuple[float, float] | tuple[float, None]z
bool | strz4None | bytes | str | tuple[bytes | str, bytes | str]zMapping[str, str] | Noner   )requeststreamtimeoutverifycertproxiesr   r    c                   s   |p| j }|j|v rfz| j|}	W n tjy<   d}	Y n0 |	rR| 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%   r+   r,   r-   r.   r/   r0   r   	cacheablecached_responserespr'   r)   r*   r:   2   s    


zCacheControlAdapter.sendr   )r+   responser1   r   r    c           
        s(  |p| j }|s|j|v r| jr*| j|}|jdkrh| j||}||urNd}|jdd |  |}nht	|jt
v r| j|| nJt|jt| jj|||_|jr|j ddd fdd	}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_contentr   r   )r%   r    c                   s      | j dkr| j  d S )Nr   )
chunk_left_fp_closer%   super_update_chunk_lengthr)   r*   _update_chunk_length   s    
z@CacheControlAdapter.build_response.<locals>._update_chunk_lengthN)r   r2   r   applystatusr$   update_cached_responsereadrelease_connintr	   cache_responser   rA   	functoolspartialchunkedrF   types
MethodTyper"   r6   invalidating_methodsokurl	cache_urlr   deleter1   )
r%   r+   r>   r1   r   r;   r<   rF   r=   rV   r'   rD   r*   r6   P   sD    


z"CacheControlAdapter.build_response)r    c                   s   | j   t   d S )N)r   closer"   rC   r'   r)   r*   rX      s    
zCacheControlAdapter.close)NTNNNN)FNTNNN)FN)	__name__
__module____qualname__rS   r#   r:   r6   rX   __classcell__r)   r)   r'   r*   r      s&         $      ""  Or   )
__future__r   rN   rQ   r4   typingr   r   r   r   Zpip._vendor.requests.adaptersr   Zpip._vendor.cachecontrol.cacher   Z#pip._vendor.cachecontrol.controllerr	   r
   Z$pip._vendor.cachecontrol.filewrapperr   Zpip._vendor.requestsr   r   Zpip._vendor.urllib3r   r   Z#pip._vendor.cachecontrol.heuristicsr   Z"pip._vendor.cachecontrol.serializer   r   r)   r)   r)   r*   <module>   s   