U
    µ©Þa  ã                   @   sN   d dl 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 )é    N)Úpatch_vary_headers)ÚMiddlewareMixin)Ú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 |¡sL|S |j rft	|j
ƒ|_
|d= n8t|jƒ}t|ƒt|jƒkr†|S ||_tt|jƒƒ|d< | d¡}|rÂ| d¡rÂd	| |d< d
|d< |S )NéÈ   zContent-Encoding)zAccept-EncodingZHTTP_ACCEPT_ENCODINGÚ zContent-LengthÚETagú"zW/Úgzip)Z	streamingÚlenÚcontentÚ
has_headerr   ZMETAÚgetÚre_accepts_gzipÚsearchr   Zstreaming_contentr   ÚstrÚ
startswith)ÚselfÚrequestÚresponseZaeZcompressed_contentÚetag© r   ú…/home/adriano.carvalho/ftp/files/BrinquedotecaVirtual/brinquedotecavirtual/venv/lib/python3.8/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   )ÚreZdjango.utils.cacher   Zdjango.utils.deprecationr   Zdjango.utils.textr   r   Úcompiler   r   r   r   r   r   Ú<module>   s
   
