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ƒ}ttddt|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 "