U
    cUh                     @  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dddh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PUTPATCHDELETENTz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           
        sP   t  j|| |d krt n|| _|| _|p.d| _|p8t}	|	| j||d| _d S )N)GET)r   r   )super__init__r   r   r   r   r
   
controller)
selfr   r   r   r   r   r   r   r   Zcontroller_factory	__class__ `/opt/bot/vods_filmes/script/venv/lib/python3.8/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|krhz| j|}	W n tjk
r>   d}	Y nX |	rT| 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$   Zcached_requestzliberrorbuild_responseheadersupdateZconditional_headersr"   send)r%   r*   r+   r,   r-   r.   r/   r   	cacheablecached_responserespr&   r(   r)   r7   2   s    


zCacheControlAdapter.sendr   )r*   responser0   r   r    c           
        s(  |p| j }|s|j|kr| jr*| j|}|jdkrh| j||}||k	rNd}|jdd |  |}nht	|jt
kr| j|| nJt|jt| jj|||_|jr|j ddd fdd	}t|||_t ||}|j| jkr|jr|jd
k	st| 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%   Zsuper_update_chunk_lengthr(   r)   _update_chunk_length   s    
z@CacheControlAdapter.build_response.<locals>._update_chunk_lengthN)r   r1   r   applystatusr$   Zupdate_cached_responsereadrelease_connintr	   Zcache_responser   r>   	functoolspartialchunkedrB   types
MethodTyper"   r4   invalidating_methodsokurlAssertionError	cache_urlr   deleter0   )
r%   r*   r;   r0   r   r8   r9   rB   r:   rQ   r&   rA   r)   r4   P   sL    

    z"CacheControlAdapter.build_response)r    c                   s   | j   t   d S )N)r   closer"   r@   r&   r(   r)   rS      s    
zCacheControlAdapter.close)NTNNNN)FNTNNN)FN)	__name__
__module____qualname__rM   r#   r7   r4   rS   __classcell__r(   r(   r&   r)   r      s&   
      $      ""  Or   )
__future__r   rH   rK   r2   typingr   r   r   r   pip._vendor.requests.adaptersr   Zpip._vendor.cachecontrol.cacher   #pip._vendor.cachecontrol.controllerr	   r
   Z$pip._vendor.cachecontrol.filewrapperr   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   