U ��.e��@s�ddlZddlZddlmZmZmZddlmZmZdZddd�Z dd�Z Gd d �d e �Z Gd d �d e �Z Gd d�de �ZGdd�de �ZdS)�N)� formatdate� parsedate� parsedate_tz)�datetime� timedeltaz%a, %d %b %Y %H:%M:%S GMTcCs|p t��}||S�N)rZutcnow)�delta�date�r �G/usr/lib/python3.8/site-packages/pip/_vendor/cachecontrol/heuristics.py� expire_after s r cCstt�|����Sr)r�calendar�timegmZ timetuple)Zdtr r r �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�responser r r �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. r rr r r �update_headers!szBaseHeuristic.update_headerscCs@|�|�}|r<|j�|�|�|�}|dk r<|j�d|i�|S)N�Warning)r�headers�updater)rrZupdated_headersZwarning_header_valuer r r �apply*s   zBaseHeuristic.applyN)�__name__� __module__� __qualname__rrrr r r r rs  rc@seZdZdZdd�ZdS)� OneDayCachezM Cache the response by providing an expires 1 day in the future. cCsRi}d|jkrNt|jd�}ttdd�t|dd��d�}t|�|d<d|d<|S) N�expiresr �)Zdays�)r �public� cache-control)rrr rrr)rrrr rr r r r<s  zOneDayCache.update_headersN)rrr�__doc__rr r r r r6src@s(eZdZdZdd�Zdd�Zdd�ZdS) � ExpiresAfterz; Cache **all** requests for a defined time period. cKstf|�|_dSr)rr)r�kwr r r �__init__LszExpiresAfter.__init__cCst|j�}t|�dd�S)Nr!)rr")r rr)rrrr r r rOs zExpiresAfter.update_headerscCsd}||jS)Nz:110 - Automatically cached for %s. Response might be stale)r)rrZtmplr r r rSszExpiresAfter.warningN)rrrr#r&rrr r r r r$Gsr$c @s:eZdZdZdddddddd d d d h Zd d�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. ��������i,i-i�i�i�i�i�c Cs�|j}d|kriSd|kr*|ddkr*iS|j|jkr:iSd|ksJd|krNiSt�t|d��}t|d�}|dks||dkr�iSt��}td||�}|t�|�}tdt |dd��}||kr�iS||} dt� t t� | ��iS) Nrr"r!r z last-modifiedr� i�Q) rZstatus�cacheable_by_default_statusesr rrr�time�max�min�strftime�TIME_FMT�gmtime) r�resprr Z last_modifiedZnowZ current_agerZfreshness_lifetimerr r r rhs*  zLastModified.update_headerscCsdSrr )rr4r r r r�szLastModified.warningN)rrrr#r-rrr r r r r'Xs �r')N)r r.Z email.utilsrrrrrr2r r�objectrrr$r'r r r r �s "