ó
^†êWc           @   sÁ   d  d l  Z  d  d l Z d  d l m Z m Z m Z d  d l m Z m Z d Z d d „ Z
 d „  Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t
   formatdatet	   parsedatet   parsedate_tz(   t   datetimet	   timedeltas   %a, %d %b %Y %H:%M:%S GMTc         C   s   | p t  j ƒ  } | |  S(   N(   R   t   now(   t   deltat   date(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   expire_after   s    c         C   s   t  t j |  j ƒ  ƒ ƒ S(   N(   R    t   calendart   timegmt	   timetuple(   t   dt(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   datetime_to_header   s    t   BaseHeuristicc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   d S(   s!  
        Return a valid 1xx warning header value describing the cache
        adjustments.

        The response is provided too allow warnings like 113
        http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need
        to explicitly say response is over 24 hours old.
        s   110 - "Response is Stale"(    (   t   selft   response(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   warning   s    	c         C   s   i  S(   sï   Update the response headers with any new headers.

        NOTE: This SHOULD always include some Warning header to
              signify that the response was cached by the client, not
              by way of the provided headers.
        (    (   R   R   (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   update_headers!   s    c         C   sa   |  j  | ƒ } | r] | j j | ƒ |  j | ƒ } | d  k	 r] | j j i | d 6ƒ q] n  | S(   Nt   Warning(   R   t   headerst   updateR   t   None(   R   R   t   updated_headerst   warning_header_value(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   apply*   s    (   t   __name__t
   __module__R   R   R   (    (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR      s   			t   OneDayCachec           B   s   e  Z d  Z d „  Z RS(   sM   
    Cache the response by providing an expires 1 day in the
    future.
    c         C   sn   i  } d | j  k rj t | j  d ƒ } t t d d ƒ d t | d  Œ  ƒ} t | ƒ | d <d | d <n  | S(   Nt   expiresR   t   daysi   i   t   publics   cache-control(   R   R   R   R   R   R   (   R   R   R   R   R   (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   ;   s    (   R   R   t   __doc__R   (    (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   6   s   t   ExpiresAfterc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s;   
    Cache **all** requests for a defined time period.
    c         K   s   t  |   |  _ d  S(   N(   R   R   (   R   t   kw(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   __init__L   s    c         C   s'   t  |  j ƒ } i t | ƒ d 6d d 6S(   NR   R   s   cache-control(   R   R   R   (   R   R   R   (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   O   s    c         C   s   d } | |  j  S(   Ns:   110 - Automatically cached for %s. Response might be stale(   R   (   R   R   t   tmpl(    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   V   s    (   R   R   R    R#   R   R   (    (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR!   G   s   		t   LastModifiedc           B   sM   e  Z d  Z e d d d d d d d d d	 d
 d g ƒ Z d „  Z d „  Z RS(   sÁ  
    If there is no Expires header already, fall back on Last-Modified
    using the heuristic from
    http://tools.ietf.org/html/rfc7234#section-4.2.2
    to calculate a reasonable value.

    Firefox also does something like this per
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ
    http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397
    Unlike mozilla we limit this to 24-hr.
    iÈ   iË   iÌ   iÎ   i,  i-  i”  i•  iš  iž  iõ  c   
      C   s8  | j  } d | k r i  Sd | k r9 | d d k r9 i  S| j |  j k rO i  Sd | k sg d | k rk i  St j t | d ƒ ƒ } t | d ƒ } | d  k s¬ | d  k r° i  St j ƒ  } t	 d | | ƒ } | t j | ƒ } t	 d t
 | d d
 ƒ ƒ } | | k ri  S| | }	 i t j t t j |	 ƒ ƒ d 6S(   NR   s   cache-controlR   R   s   last-modifiedi    i
   i   i  i€Q (   R   t   statust   cacheable_by_default_statusesR	   R
   R   R   R   t   timet   maxt   mint   strftimet   TIME_FMTt   gmtime(
   R   t   respR   R   t   last_modifiedR   t   current_ageR   t   freshness_lifetimeR   (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   k   s*    	
c         C   s   d  S(   N(   R   (   R   R.   (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR   ‰   s    (   R   R   R    t   setR'   R   R   (    (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyR%   [   s
   *	(   R	   R(   t   email.utilsR    R   R   R   R   R,   R   R   R   t   objectR   R   R!   R%   (    (    (    st   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/cachecontrol/heuristics.pyt   <module>   s   	"