B
    ª0H[d  ã               @   s@   d dl mZmZmZ d dlmZ d dlmZ G dd„ deƒZdS )é    )Úcc_delim_reÚget_conditional_responseÚset_response_etag)ÚMiddlewareMixin)Úparse_http_date_safec               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚConditionalGetMiddlewarezé
    Handle conditional GET operations. If the response has an ETag or
    Last-Modified header and the request has If-None-Match or If-Modified-Since,
    replace the response with HttpNotModified. Add an ETag header if needed.
    c             C   sf   |j dkr|S |  |¡r*| d¡s*t|ƒ | d¡}| d¡}|rJt|ƒ}|sR|rbt||||d�S |S )NÚGETÚETagzLast-Modified)ÚetagÚlast_modifiedÚresponse)ÚmethodÚ
needs_etagÚ
has_headerr   Úgetr   r   )ÚselfÚrequestr   r
   r   © r   úZC:\Users\HIRONO~1\AppData\Local\Temp\pip-install-6bm3nxem\django\django\middleware\http.pyÚprocess_response   s    


z)ConditionalGetMiddleware.process_responsec             C   s$   t  | dd¡¡}tdd„ |D ƒƒS )z:Return True if an ETag header should be added to response.zCache-ControlÚ c             s   s   | ]}|  ¡ d kV  qdS )zno-storeN)Úlower)Ú.0Úheaderr   r   r   ú	<genexpr>*   s    z6ConditionalGetMiddleware.needs_etag.<locals>.<genexpr>)r   Úsplitr   Úall)r   r   Zcache_control_headersr   r   r   r   '   s    z#ConditionalGetMiddleware.needs_etagN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s   r   N)	Zdjango.utils.cacher   r   r   Zdjango.utils.deprecationr   Zdjango.utils.httpr   r   r   r   r   r   Ú<module>   s   