
    /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dS )    N)
formatdate	parsedateparsedate_tz)datetime	timedeltaz%a, %d %b %Y %H:%M:%S GMTc                 6    |pt          j                    }|| z   S N)r   utcnow)deltadates     V/var/www/html/venv/lib/python3.11/site-packages/pip/_vendor/cachecontrol/heuristics.pyexpire_afterr      s    $8?$$D%<    c                 h    t          t          j        |                                                     S r	   )r   calendartimegm	timetuple)dts    r   datetime_to_headerr      s"    hobllnn55666r   c                        e Zd Zd Zd Zd ZdS )BaseHeuristicc                     dS )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                     |                      |          }|rM|j                            |           |                     |          }||j                            d|i           |S )NWarning)r   headersupdater   )r   r   updated_headerswarning_header_values       r   applyzBaseHeuristic.apply.   so    --h77 	K##O444#'<<#9#9 #/ ''4H(IJJJr   N)__name__
__module____qualname__r   r   r&   r   r   r   r   r      sA        	+ 	+ 	+  	 	 	 	 	r   r   c                       e Zd ZdZd ZdS )OneDayCachezM
    Cache the response by providing an expires 1 day in the
    future.
    c                     i }d|j         vr_t          |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@   su    H,,,X-f566D"9!#4#4#48T"1"X;NOO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dS )ExpiresAfterz;
    Cache **all** requests for a defined time period.
    c                 (    t          di || _        d S )Nr   )r   r   )r   kws     r   __init__zExpiresAfter.__init__P   s    ____


r   c                 N    t          | j                  }t          |          ddS )Nr1   )r-   r2   )r   r   r   )r   r   r-   s      r   r   zExpiresAfter.update_headersS   s'    tz**-g66R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dj  r   N)r'   r(   r)   r3   r8   r   r   r   r   r   r5   r5   K   sN         % % %S S S! ! ! ! !r   r5   c                   &    e Zd ZdZh dZd Zd ZdS )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k    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*NI;d@@@I  O7$B$BI|GFO<<==!'/":;;<=0Iikk!S4Z((x}555 C
I$>$>??,,I++4=4;w3G3GHHIIr   c                     d S r	   r   )r   rS   s     r   r   zLastModified.warning   s    tr   N)r'   r(   r)   r3   rL   r   r   r   r   r   r=   r=   \   sQ        
 
% % %!J J J<    r   r=   r	   )r   rM   email.utilsr   r   r   r   r   rQ   r   r   objectr   r+   r5   r=   r   r   r   <module>r[      s*  
   ; ; ; ; ; ; ; ; ; ; ( ( ( ( ( ( ( (&   
7 7 7    F   D    -   "! ! ! ! != ! ! !"/ / / / /= / / / / /r   