o
ai @ s\ d dl Z d dlZd dlZd dlmZ ddlmZ ddlmZ ddl m
Z
G dd deZdS ) N)HTTPAdapter )CacheController) DictCache)CallbackFileWrapperc s\ e Zd ZddhZ d fdd Zd fdd Z d fd
d Z fdd
Z ZS )CacheControlAdapterPUTDELETENTc
sX t t| j|i | |d u rt n|| _|| _|pd| _|p t} | | j||d| _d S )N)GET)cache_etags
serializer) superr __init__r cache heuristiccacheable_methodsr
controller)
selfr r controller_classr r r argskwcontroller_factory __class__ /builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/cachecontrol/adapter.pyr s
zCacheControlAdapter.__init__c s |p| j }|j|v r3z| j|}W n tjy d}Y nw |r)| j||ddS |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_requestzliberrorbuild_responseheadersupdateconditional_headersr
r send)r requestr r cacheablecached_responserespr r r r% $ s
zCacheControlAdapter.sendFc
s |p| j }|sb|j|v rb| jr| j|}|jdkr4| j||}||ur'd}|jdd | |}n.|jdkrA| j || n!t
|jt
| jj |||_|jrb|j fdd}t|||_tt| ||}|j| jv r|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
i0 TF)decode_contenti- c s" | j dkr| j d S d S )Nr )
chunk_left_fp_closer super_update_chunk_lengthr r _update_chunk_lengthn s
z@CacheControlAdapter.build_response.