Viewing File: /usr/lib/python3.6/site-packages/pip/_vendor/cachecontrol/__pycache__/heuristics.cpython-36.pyc

3

aj-@sddlZddlZddlmZmZmZddlmZmZdZdddZ	ddZ
Gd	d
d
eZGdddeZ
Gd
ddeZGdddeZdS)N)
formatdate	parsedateparsedate_tz)datetime	timedeltaz%a, %d %b %Y %H:%M:%S GMTcCs|p
tj}||S)N)rnow)deltadater
 /usr/lib/python3.6/heuristics.pyexpire_aftersrcCsttj|jS)N)rcalendartimegmZ	timetuple)Zdtr
r
rdatetime_to_headersrc@s$eZdZddZddZddZdS)
BaseHeuristiccCsdS)a!
        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.
        z110 - "Response is Stale"r
)selfresponser
r
rwarnings	zBaseHeuristic.warningcCsiS)zUpdate 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
)rrr
r
rupdate_headers!szBaseHeuristic.update_headerscCs@|j|}|r<|jj||j|}|dk	r<|jjd|i|S)NWarning)rheadersupdater)rrZupdated_headersZwarning_header_valuer
r
rapply*s

zBaseHeuristic.applyN)__name__
__module____qualname__rrrr
r
r
rrs	rc@seZdZdZddZdS)OneDayCachezM
    Cache the response by providing an expires 1 day in the
    future.
    cCsRi}d|jkrNt|jd}ttddt|ddd}t||d<d|d<|S)	Nexpiresr	)Zdays)r	publicz
cache-control)rrrrrr)rrrr	rr
r
rr;s

zOneDayCache.update_headersN)rrr__doc__rr
r
r
rr6src@s(eZdZdZddZddZddZdS)	ExpiresAfterz;
    Cache **all** requests for a defined time period.
    cKstf||_dS)N)rr)rkwr
r
r__init__LszExpiresAfter.__init__cCst|j}t|ddS)Nr )rz
cache-control)rrr)rrrr
r
rrOs
zExpiresAfter.update_headerscCsd}||jS)Nz:110 - Automatically cached for %s. Response might be stale)r)rrZtmplr
r
rrVszExpiresAfter.warningN)rrrr!r$rrr
r
r
rr"Gsr"c@s>eZdZdZedddddddd	d
ddgZd
dZddZdS)LastModifieda
    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-iiiiic
Cs|j}d|kriSd|kr*|ddkr*iS|j|jkr:iSd|ksJd|krNiStjt|d}t|d}|dks||dkriStj}td||}|tj|}tdt	|dd
}||kriS||}	dtj
ttj|	iS)Nrz
cache-controlr r	z
last-modifiedr
iiQ)
rZstatuscacheable_by_default_statusesr
rrrtimemaxminZstrftimeTIME_FMTZgmtime)
rresprr	Z
last_modifiedrZcurrent_agerZfreshness_lifetimerr
r
rrks*zLastModified.update_headerscCsdS)Nr
)rr1r
r
rrszLastModified.warningN)rrrr!setr,rrr
r
r
rr%[s
r%)N)r
r-Zemail.utilsrrrrrr0rrobjectrrr"r%r
r
r
r<module>s
"
Back to Directory File Manager