
    *,h:                         d dl Z d dlZd dlmZmZmZ d dlmZmZ dZddZ	d Z
 G d de      Z G d	 d
e      Z G d de      Z G d de      Zy)    N)
formatdate	parsedateparsedate_tz)datetime	timedeltaz%a, %d %b %Y %H:%M:%S GMTc                 <    |xs t        j                         }|| z   S N)r   utcnow)deltadates     e/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_vendor/cachecontrol/heuristics.pyexpire_afterr      s    $8??$D%<    c                 Z    t        t        j                  | j                                     S r	   )r   calendartimegm	timetuple)dts    r   datetime_to_headerr      s    hooblln566r   c                       e Zd Zd Zd Zd Zy)BaseHeuristicc                      y)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.
        z110 - "Response is Stale" selfresponses     r   warningzBaseHeuristic.warning   s     +r   c                     i S )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     r   update_headerszBaseHeuristic.update_headers%   s	     	r   c                     | j                  |      }|rK|j                  j                  |       | j                  |      }||j                  j                  d|i       |S )NWarning)r   headersupdater   )r   r   updated_headerswarning_header_values       r   applyzBaseHeuristic.apply.   s]    --h7##O4#'<<#9 #/  ''4H(IJr   N)__name__
__module____qualname__r   r   r&   r   r   r   r   r      s    	+	r   r   c                       e Zd ZdZd Zy)OneDayCachezM
    Cache the response by providing an expires 1 day in the
    future.
    c                     i }d|j                   vrKt        |j                   d         }t        t        d      t	        |d d        }t        |      |d<   d|d<   |S )	Nexpiresr      )days   )r   publiccache-control)r"   r   r   r   r   r   )r   r   r"   r   r-   s        r   r   zOneDayCache.update_headers@   sd    H,,,X--f56D"9!#48T"1X;NOG!3G!<GI'/GO$r   N)r'   r(   r)   __doc__r   r   r   r   r+   r+   :   s    
r   r+   c                   "    e Zd ZdZd Zd Zd Zy)ExpiresAfterz;
    Cache **all** requests for a defined time period.
    c                 $    t        di || _        y )Nr   )r   r   )r   kws     r   __init__zExpiresAfter.__init__P   s    __
r   c                 H    t        | j                        }t        |      ddS )Nr1   )r-   r2   )r   r   r   )r   r   r-   s      r   r   zExpiresAfter.update_headersS   s     tzz*-g6RRr   c                 $    d}|| j                   z  S )Nz:110 - Automatically cached for %s. Response might be stale)r   )r   r   tmpls      r   r   zExpiresAfter.warningW   s    Kdjj  r   N)r'   r(   r)   r3   r8   r   r   r   r   r   r5   r5   K   s    %S!r   r5   c                   $    e Zd ZdZh dZd Zd Zy)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|v ri S d|v r
|d   dk7  ri S |j                  | j                  vri S d|vsd|vri S t        j                  t        |d               }t        |d         }||i S t        j                         }t        d||z
        }|t        j                  |      z
  }t        dt        |dz  d            }||k  ri S ||z   }	dt        j                  t        t        j                  |	            iS )	Nr-   r2   r1   r   zlast-modifiedr   
   iQ )r"   statuscacheable_by_default_statusesr   r   r   r   timemaxminstrftimeTIME_FMTgmtime)
r   respr"   r   last_modifiednowcurrent_ager   freshness_lifetimer-   s
             r   r   zLastModified.update_headersl   s   ,,Ig%'/*Bh*NI;;d@@@I O7$BI|GFO<=!'/":;<=0Iiik!S4Z(x}55 C
I$>?,I++4==4;;w3GHIIr   c                      y r	   r   )r   rS   s     r   r   zLastModified.warning   s    r   N)r'   r(   r)   r3   rL   r   r   r   r   r   r=   r=   \   s    
%!J<r   r=   r	   )r   rM   email.utilsr   r   r   r   r   rQ   r   r   objectr   r+   r5   r=   r   r   r   <module>r[      sV   
   ; ; (&
7F D- "!= !"/= /r   