관리-도구
편집 파일: heuristics.cpython-39.pyc
a ����[��f�����������������������@���s����d�dl�Z�d�dlZd�dlmZmZmZ�d�dlmZmZ�dZddd�Z dd��Z G�d d ��d e�ZG�dd��de�Z G�d d��de�ZG�dd��de�ZdS�)�����N)� formatdate� parsedate�parsedate_tz)�datetime� timedeltaz%a, %d %b %Y %H:%M:%S GMTc�����������������C���s���|p t����}||��S��N)r���Zutcnow)�delta�date��r ����G/usr/lib/python3.9/site-packages/pip/_vendor/cachecontrol/heuristics.py�expire_after���s����r���c�����������������C���s���t�t�|������S�r���)r����calendar�timegmZ timetuple)Zdtr ���r ���r����datetime_to_header���s����r���c�������������������@���s$���e�Zd�Zdd��Zdd��Zdd��ZdS�)� BaseHeuristicc�����������������C���s���dS�)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����warning���s���� zBaseHeuristic.warningc�����������������C���s���i�S�)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 ���r���r ���r ���r����update_headers!���s����zBaseHeuristic.update_headersc�����������������C���s@���|���|�}|r<|j�|��|��|�}|d�ur<|j�d|i��|S�)N�Warning)r����headers�updater���)r���r���Zupdated_headersZwarning_header_valuer ���r ���r����apply*���s���� zBaseHeuristic.applyN)�__name__� __module__�__qualname__r���r���r���r ���r ���r ���r���r������s��� r���c�������������������@���s���e�Zd�ZdZdd��ZdS�)�OneDayCachezM Cache the response by providing an expires 1 day in the future. c�����������������C���sR���i�}d|j�vrNt|j�d��}ttdd�t|d�d����d�}t|�|d<�d|d<�|S�) N�expiresr �������)Zdays����)r ����public� cache-control)r���r���r���r���r���r���)r���r���r���r ���r���r ���r ���r���r���<���s���� zOneDayCache.update_headersN)r���r���r����__doc__r���r ���r ���r ���r���r���6���s���r���c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �ExpiresAfterz; Cache **all** requests for a defined time period. c�����������������K���s���t�f�i�|��|�_d�S�r���)r���r���)r����kwr ���r ���r����__init__L���s����zExpiresAfter.__init__c�����������������C���s���t�|�j�}t|�dd�S�)Nr!���)r���r"���)r���r���r���)r���r���r���r ���r ���r���r���O���s���� zExpiresAfter.update_headersc�����������������C���s���d}||�j��S�)Nz:110 - Automatically cached for %s. Response might be stale)r���)r���r���Ztmplr ���r ���r���r���S���s����zExpiresAfter.warningN)r���r���r���r#���r&���r���r���r ���r ���r ���r���r$���G���s���r$���c�������������������@���s(���e�Zd�ZdZh�d�Zdd��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����������� ������C���s����|j�}d|v�ri�S�d|v�r*|d�dkr*i�S�|j|�jvr:i�S�d|vsJd|vrNi�S�t�t|d���}t|d��}|d�u�s||d�u�r�i�S�t���}td||��}|t�|��}tdt |d�d��}||kr�i�S�||�} dt� tt�| ��iS�) Nr���r"���r!���r ���z last-modifiedr���� ���i�Q�) r����status�cacheable_by_default_statusesr ���r���r���r����time�max�min�strftime�TIME_FMT�gmtime) r����respr���r ���Z last_modifiedZnowZcurrent_ager���Zfreshness_lifetimer���r ���r ���r���r���h���s*����zLastModified.update_headersc�����������������C���s���d�S�r���r ���)r���r5���r ���r ���r���r�������s����zLastModified.warningN)r���r���r���r#���r.���r���r���r ���r ���r ���r���r'���X���s���r'���)N)r ���r/���Zemail.utilsr���r���r���r���r���r3���r���r����objectr���r���r$���r'���r ���r ���r ���r����<module>���s��� "