o
    æË·e_  ã                   @   sP   d dl mZ d dlmZ d dlmZ d dlmZmZ edƒZ	G dd„ deƒZ
dS )	é    )Úpatch_vary_headers)ÚMiddlewareMixin)Ú_lazy_re_compile)Úcompress_sequenceÚcompress_stringz\bgzip\bc                   @   s   e Zd ZdZdd„ ZdS )ÚGZipMiddlewarez±
    Compress content if the browser allows gzip compression.
    Set the Vary header accordingly, so that caches will base their storage
    on the Accept-Encoding header.
    c                 C   sÖ   |j st|jƒdk r|S | d¡r|S t|dƒ |j dd¡}t |¡s&|S |j r4t	|j
ƒ|_
|jd= nt|jƒ}t|ƒt|jƒkrD|S ||_tt|jƒƒ|jd< | d¡}|rd| d¡rdd	| |jd< d
|jd< |S )NéÈ   zContent-Encoding)zAccept-EncodingÚHTTP_ACCEPT_ENCODINGÚ zContent-LengthÚETagú"zW/Úgzip)Ú	streamingÚlenÚcontentÚ
has_headerr   ÚMETAÚgetÚre_accepts_gzipÚsearchr   Ústreaming_contentÚheadersr   ÚstrÚ
startswith)ÚselfÚrequestÚresponseÚaeÚcompressed_contentÚetag© r    úM/var/www/ideatree/venv/lib/python3.10/site-packages/django/middleware/gzip.pyÚprocess_response   s*   






zGZipMiddleware.process_responseN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r"   r    r    r    r!   r   	   s    r   N)Údjango.utils.cacher   Údjango.utils.deprecationr   Údjango.utils.regex_helperr   Údjango.utils.textr   r   r   r   r    r    r    r!   Ú<module>   s    