U
    aX                     @   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}|oHt|}|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   /home/adriano.carvalho/ftp/files/BrinquedotecaVirtual/brinquedotecavirtual/venv/lib/python3.8/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   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   