o
    lfP                     @   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}|o$t|}|s)|r1t||||dS |S )NGETETagzLast-Modified)etaglast_modifiedresponse)method
needs_etag
has_headerr   getr   r   )selfrequestr   r
   r    r   Z/var/www/ticemtrilhas/avaliacao_env/lib/python3.10/site-packages/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   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)	django.utils.cacher   r   r   django.utils.deprecationr   django.utils.httpr   r   r   r   r   r   <module>   s    