관리-도구
편집 파일: adapter.cpython-36.pyc
3 �Re � @ s\ d dl Z d dlZd dlZd dlmZ ddlmZ ddlmZ ddl m Z G dd� de�ZdS ) � N)�HTTPAdapter� )�CacheController)� DictCache)�CallbackFileWrapperc sN e Zd ZddhZd� fdd� Zd� fdd� Zd� fd d� Z� fdd �Z� ZS )�CacheControlAdapter�PUT�DELETENTc sT t t| �j||� |d kr t� n|| _|| _|p2d| _|p<t} | | j||d�| _d S )N�GET)�cache_etags� serializer)r ) �superr �__init__r �cache� heuristic�cacheable_methodsr � controller) �selfr r �controller_classr r r �args�kw�controller_factory)� __class__� ��/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/cachecontrol/adapter.pyr s zCacheControlAdapter.__init__c s� |p| j }|j|krhy| jj|�}W n tjk r> d}Y nX |rT| j||dd�S |jj| jj |�� t t| �j|f|�}|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 r �send)r �requestr r � cacheable�cached_response�resp)r r r r$ $ s zCacheControlAdapter.sendFc s |p| j }| r�|j|kr�| jr,| jj|�}|jdkrj| jj||�}||k rPd}|jdd� |j� |}n\|jdkr�| jj ||� nBt |jtj | jj ||��|_|jr�|j� � fdd�}tj||�|_tt| �j||�}|j| jko�|j�r| jj|j�} | jj| � ||_|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| jj� d S )Nr )� chunk_left�_fp�_close)r )�super_update_chunk_lengthr r �_update_chunk_lengthn s z@CacheControlAdapter.build_response.<locals>._update_chunk_length)r r r �apply�statusr �update_cached_response�read�release_conn�cache_responser r+ � functools�partial�chunkedr. �types� MethodTyper r r �invalidating_methods�ok� cache_url�urlr �deleter ) r r% �responser r r&