3
(h                 @   s@   d dl mZ d dlmZ d dlmZmZmZ G dd deZdS )    )get_conditional_response)MiddlewareMixin)	http_dateparse_http_date_safeunquote_etagc               @   s   e Zd ZdZdd ZdS )ConditionalGetMiddlewarea  
    Handles conditional GET operations. If the response has an ETag or
    Last-Modified header, and the request has If-None-Match or
    If-Modified-Since, the response is replaced by an HttpNotModified.

    Also sets the Date and Content-Length response-headers.
    c             C   sp   t  |d< |j r0|jd r0tt|j|d< |jd}|jd}|rPt|}|sX|rlt|t	|||dS |S )NDatezContent-LengthETagzLast-Modified)etaglast_modifiedresponse)
r   Z	streaming
has_headerstrlencontentgetr   r   r   )selfrequestr   r
   r    r   :/tmp/pip-install-q3hcpn_q/Django/django/middleware/http.pyprocess_response   s    


z)ConditionalGetMiddleware.process_responseN)__name__
__module____qualname____doc__r   r   r   r   r   r      s   r   N)	Zdjango.utils.cacher   Zdjango.utils.deprecationr   Zdjango.utils.httpr   r   r   r   r   r   r   r   <module>   s   