ó
Ð²Ebc           @   s~   d  d l  Z  d  d l Z d  d l Z d  d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d e f d „  ƒ  YZ d S(	   iÿÿÿÿN(   t   HTTPAdapteri   (   t   CacheController(   t	   DictCache(   t   CallbackFileWrappert   CacheControlAdapterc           B   sS   e  Z d  d h Z d e d d d d d „ Z d d „ Z e d d „ Z d „  Z	 RS(   t   PUTt   DELETEc   
      O   s}   t  t |  ƒ j | | Ž  | d  k r. t ƒ  n | |  _ | |  _ | pI d |  _ | pX t }	 |	 |  j d | d | ƒ|  _	 d  S(   Nt   GETt   cache_etagst
   serializer(   R   (
   t   superR   t   __init__t   NoneR   t   cachet	   heuristict   cacheable_methodsR   t
   controller(
   t   selfR   R   t   controller_classR	   R   R   t   argst   kwt   controller_factory(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyR      s    	c         K   s«   | p |  j  } | j | k rŒ y |  j j | ƒ } Wn t j k
 rP d } n X| rm |  j | | d t ƒS| j	 j
 |  j j | ƒ ƒ n  t t |  ƒ j | |  } | S(   s”   
        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.
        t
   from_cacheN(   R   t   methodR   t   cached_requestt   zlibt   errorR   t   build_responset   Truet   headerst   updatet   conditional_headersR
   R   t   send(   R   t   requestR   R   t	   cacheablet   cached_responset   resp(    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyR    $   s    
c   
         s•  | p |  j  } | r*| j | k r*|  j rC |  j j | ƒ } n  | j d k rŸ |  j j | | ƒ } | | k	 r| t } n  | j d t	 ƒ | j
 ƒ  | } q*| j d k rÄ |  j j | | ƒ q*t | j t j |  j j | | ƒ ƒ | _ | j r*| j ‰  ‡  f d †  } t j | | ƒ | _ q*n  t t |  ƒ j | | ƒ } | j |  j k rˆ| j rˆ|  j j | j ƒ }	 |  j j |	 ƒ n  | | _ | S(   s¥   
        Build a response by making a request or using the cache.

        This will end up calling send and returning a potentially
        cached response
        i0  t   decode_contenti-  c            s*   ˆ  ƒ  |  j  d k r& |  j j ƒ  n  d  S(   Ni    (   t
   chunk_leftt   _fpt   _close(   R   (   t   super_update_chunk_length(    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyt   _update_chunk_lengthn   s    (   R   R   R   t   applyt   statusR   t   update_cached_responseR   t   readt   Falset   release_connt   cache_responseR   R'   t	   functoolst   partialt   chunkedR*   t   typest
   MethodTypeR
   R   R   t   invalidating_methodst   okt	   cache_urlt   urlR   t   deleteR   (
   R   R!   t   responseR   R   R"   R#   R*   R$   R9   (    (   R)   s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyR   9   s:    				
				c         C   s$   |  j  j ƒ  t t |  ƒ j ƒ  d  S(   N(   R   t   closeR
   R   (   R   (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyR=   ƒ   s    N(
   t   __name__t
   __module__R7   R   R   R   R    R/   R   R=   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyR      s   I(   R5   R2   R   t   pip._vendor.requests.adaptersR    R   R   R   R   t   filewrapperR   R   (    (    (    s=   /tmp/pip-build-UPPWic/pip/pip/_vendor/cachecontrol/adapter.pyt   <module>   s   