File: //usr/local/lib/python3.7/site-packages/pip/_vendor/cachecontrol/__pycache__/adapter.cpython-37.pyc
B
L��g� � @ s� d dl mZ d dlZd dlZd dlZd dlmZmZmZm Z d dl
mZ d dlm
Z
d dlmZmZ d dlmZ er�d dlmZmZ d d lmZ d d
lmZ d dlmZ d dlmZ G d
d� de�ZdS )� )�annotationsN)�
TYPE_CHECKING�Any�
Collection�Mapping)�HTTPAdapter)� DictCache)�PERMANENT_REDIRECT_STATUSES�CacheController)�CallbackFileWrapper)�PreparedRequest�Response)�HTTPResponse)� BaseCache)�
BaseHeuristic)�
Serializerc s� e Zd ZdddhZd"dddd d
dddd
d� � fdd�
Zd#ddddddddd�� fdd�
Zd$dddddd�� fdd�
Zd
d�� fd d!�Z� ZS )%�CacheControlAdapter�PUT�PATCH�DELETENTzBaseCache | None�boolztype[CacheController] | NonezSerializer | NonezBaseHeuristic | NonezCollection[str] | Noner �None) �cache�cache_etags�controller_class�
serializer� heuristic�cacheable_methods�args�kw�returnc
sP t � j||� |d krt� 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 �controller_factory)� __class__� �D/tmp/pip-unpacked-wheel-hv55ucu3/pip/_vendor/cachecontrol/adapter.pyr# s
zCacheControlAdapter.__init__Fr z7None | float | tuple[float, float] | tuple[float, None]z
bool | strz4None | bytes | str | tuple[bytes | str, bytes | str]zMapping[str, str] | Noner
)�request�stream�timeout�verify�cert�proxiesr r c s� |p| j }|j|krhy| j�|�} W n tjk
r> d} Y nX | rT| j|| dd�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"