HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pip/_vendor/cachecontrol/__pycache__/adapter.cpython-310.pyc
o

@%Ne��@s`ddlZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZGdd�de�ZdS)	�N)�HTTPAdapter�)�CacheController�PERMANENT_REDIRECT_STATUSES)�	DictCache)�CallbackFileWrappercs\eZdZhd�Z						d
�fdd�	Zd�fdd�	Z	d�fd	d
�	Z�fdd�Z�ZS)�CacheControlAdapter>�PUT�PATCH�DELETENTc
sXtt|�j|i|��|durt�n||_||_|pd|_|p t}	|	|j||d�|_dS)N)�GET)�cache_etags�
serializer)	�superr�__init__r�cache�	heuristic�cacheable_methodsr�
controller)
�selfrr
�controller_classrrr�args�kw�controller_factory��	__class__��B/usr/lib/python3/dist-packages/pip/_vendor/cachecontrol/adapter.pyrs
�zCacheControlAdapter.__init__cs�|p|j}|j|vr3z|j�|�}Wntjyd}Ynw|r)|j||dd�S|j�|j�	|��t
t|�j|fi|��}|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_headersrr�send)r�requestrr�	cacheable�cached_response�resprrrr'(s

�zCacheControlAdapter.sendFc
s|p|j}|sd|j|vrd|jr|j�|�}|jdkr4|j�||�}||ur'd}|jdd�|��|}n0t	|j�t
vrC|j�||�n!t|j
t�|jj||��|_
|jrd|j��fdd�}t�||�|_tt|��||�}|j|jvr�|jr�|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
        i0TF)�decode_contentcs"��|jdkr|j��dSdS)Nr)�
chunk_left�_fp�_close�r��super_update_chunk_lengthrr�_update_chunk_lengthrs
�z@CacheControlAdapter.build_response.<locals>._update_chunk_length)rrr�apply�statusr�update_cached_response�read�release_conn�intr�cache_responserr.�	functools�partial�chunkedr3�types�
MethodTyperrr#�invalidating_methods�ok�	cache_url�urlr�deleter)
rr(�responserrr)r*r3r+rBrr1rr#=sB
	
�
���z"CacheControlAdapter.build_responsecs|j��tt|���dS�N)r�closerrr0rrrrG�s
zCacheControlAdapter.close)NTNNNNrF)FN)	�__name__�
__module__�__qualname__r@rr'r#rG�
__classcell__rrrrrs��Jr)
r>r;r!�pip._vendor.requests.adaptersrrrrrr�filewrapperrrrrrr�<module>s