î
Ý^Q\†  ã               @   sV   d  d l  m Z m Z m Z d  d l m Z d  d l m Z Gd 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ù
    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. An ETag
    header is added if needed.
    c             C   sž   | j  d k r | S|  j | ƒ r? | j d ƒ r? t | ƒ n  | j d ƒ } | j d ƒ } | rr t | ƒ } n  | s~ | rš t | d | d | d | ƒS| S)NÚGETZETagzLast-ModifiedÚetagÚlast_modifiedÚresponse)ÚmethodÚ
needs_etagÚ
has_headerr   Úgetr   r   )ÚselfÚrequestr   r	   r
   © r   ú</var/www/dbchiro/venv/build/Django/django/middleware/http.pyÚprocess_response   s    z)ConditionalGetMiddleware.process_responsec             C   s2   t  j | j d d ƒ ƒ } t d d „  | Dƒ ƒ S)zL
        Return True if an ETag header should be added to response.
        zCache-ControlÚ c             s   s!   |  ] } | j  ƒ  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   