\hddlmZddlZddlZddlmZmZmZddlmZm Z m Z ddl m Z m Z mZe rddlmZdZdddZdd ZGd d ZGd d eZGddeZGddeZy)) annotationsN)datetime timedeltatimezone) formatdate parsedate parsedate_tz) TYPE_CHECKINGAnyMapping) HTTPResponsez%a, %d %b %Y %H:%M:%S GMTcZ|xs#tjtj}||zSN)rnowrutc)deltadates f/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.py expire_afterrs#  -8<< -D %<cZttj|jSr)rcalendartimegm timetuple)dts rdatetime_to_headerrs hooblln5 66rc$eZdZddZddZddZy) BaseHeuristiccy)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"selfresponses rwarningzBaseHeuristic.warnings+rciS)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 r!s rupdate_headerszBaseHeuristic.update_headers's  rc|j|}|rK|jj||j|}||jjd|i|S)NWarning)r&headersupdater$)r"r#updated_headerswarning_header_values rapplyzBaseHeuristic.apply0s]--h7     # #O 4#'<<#9 #/  ''4H(IJrNr#r return str | Noner#r r/dict[str, str])r#r r/r )__name__ __module__ __qualname__r$r&r-r rrrrs + rrceZdZdZddZy) OneDayCachezM Cache the response by providing an expires 1 day in the future. ci}d|jvr\t|jd}ttdt |dddt j i}t||d<d|d <|S) Nexpiresr)daystzinfo)rpublic cache-control)r)rrrrrrr)r"r#r)rr9s rr&zOneDayCache.update_headersBsp H,, ,X--f56D"9!#48T"1X;cV^VbVb;cdG!3G!)r9r?)rrr)r"r#r9s rr&zExpiresAfter.update_headersUs tzz*-g6RRrc$d}||jzS)Nz:110 - Automatically cached for %s. Response might be stale)r)r"r#tmpls rr$zExpiresAfter.warningYsKdjj  rN)rDr r/Noner1r.)r3r4r5r@rEr&r$r rrrBrBMs%S!rrBc(eZdZdZhdZddZddZy) 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 |j}d|vriSd|vr |ddk7riS|j|jvriSd|vsd|vriSt|d}|Jt j |dd}t |d}|iStj}td||z }|t j |z }tdt|dz d } | |kriS|| z} dtjttj| iS) Nr9r?r>rz last-modifiedr<r iQ) r)statuscacheable_by_default_statusesr rrrtimemaxminstrftimeTIME_FMTgmtime) r"respr) time_tupler last_modifiedr current_agerfreshness_lifetimer9s rr&zLastModified.update_headersys!%)\\  I g %'/*Bh*NI ;;d@@ @I  O7$BI!'&/2 %%%z"1~.!'/":;  Iiik!S4Z( x}55 C I$>?  ,I++4==4;;w3GHIIrcyrr )r"ras rr$zLastModified.warningsrN)rar r/r2)rar r/r0)r3r4r5r@rZr&r$r rrrKrK^s  %!J@rrKr)rrrzdatetime | Noner/r)rrr/str) __future__rrr[rrr email.utilsrrr typingr r r pip._vendor.urllib3r r_rrrr7rBrKr rrrlsf# 22;;..0 & 7B-"!=!"<=<r