HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_vendor/cachecontrol/__pycache__/heuristics.cpython-310.pyc
o

@%Ne:�@s�ddlZddlZddlmZmZmZddlmZmZdZddd�Z	dd�Z
Gd	d
�d
e�ZGdd�de�Z
Gd
d�de�ZGdd�de�ZdS)�N)�
formatdate�	parsedate�parsedate_tz)�datetime�	timedeltaz%a, %d %b %Y %H:%M:%S GMTcCs|pt��}||S�N)r�utcnow)�delta�date�r�E/usr/lib/python3/dist-packages/pip/_vendor/cachecontrol/heuristics.py�expire_aftersr
cCstt�|����Sr)r�calendar�timegm�	timetuple)�dtrrr�datetime_to_headersrc@s$eZdZdd�Zdd�Zdd�ZdS)�
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��self�responserrr�warnings	zBaseHeuristic.warningcCsiS)z�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.
        rrrrr�update_headers%szBaseHeuristic.update_headerscCs@|�|�}|r|j�|�|�|�}|dur|j�d|i�|S)N�Warning)r�headers�updater)rr�updated_headers�warning_header_valuerrr�apply.s

zBaseHeuristic.applyN)�__name__�
__module__�__qualname__rrrrrrrrs	rc@seZdZdZdd�ZdS)�OneDayCachezM
    Cache the response by providing an expires 1 day in the
    future.
    cCsRi}d|jvr't|jd�}ttdd�t|dd��d�}t|�|d<d|d<|S)	N�expiresr
�)�days�)r
�public�
cache-control)rrr
rrr)rrrr
r#rrrr@s
zOneDayCache.update_headersN)rr r!�__doc__rrrrrr":sr"c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ExpiresAfterz;
    Cache **all** requests for a defined time period.
    cKstdi|��|_dS)Nr)rr	)r�kwrrr�__init__PszExpiresAfter.__init__cCst|j�}t|�dd�S)Nr')r#r()r
r	r)rrr#rrrrSs
zExpiresAfter.update_headerscCsd}||jS)Nz:110 - Automatically cached for %s. Response might be stale)r	)rr�tmplrrrrWs
zExpiresAfter.warningN)rr r!r)r,rrrrrrr*Ks
r*c@s(eZdZdZhd�Zdd�Zdd�ZdS)�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.
    >�,�-�������������c
Cs�|j}d|vr	iSd|vr|ddkriS|j|jvriSd|vs%d|vr'iSt�t|d��}t|d�}|dus>|dur@iSt��}td||�}|t�|�}tdt	|dd��}||krbiS||}	dt�
tt�|	��iS)	Nr#r(r'r
z
last-modifiedr�
i�Q)
r�status�cacheable_by_default_statusesrrrr�time�max�min�strftime�TIME_FMT�gmtime)
r�resprr
�
last_modified�now�current_ager	�freshness_lifetimer#rrrrls*zLastModified.update_headerscCsdSrr)rrCrrrr�szLastModified.warningN)rr r!r)r<rrrrrrr.\s
r.r)rr=�email.utilsrrrrrrAr
r�objectrr"r*r.rrrr�<module>s
"