
    h>                     ^    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e      Z
y)	    )patch_vary_headers)MiddlewareMixin)_lazy_re_compile)compress_sequencecompress_stringz\bgzip\bc                       e Zd ZdZd Zy)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                 l   |j                   st        |j                        dk  r|S |j                  d      r|S t	        |d       |j
                  j                  dd      }t        j                  |      s|S |j                   rt        |j                        |_
        |d= n`t        |j                        }t        |      t        |j                        k\  r|S ||_        t        t        |j                              |d<   |j                  d      }|r|j                  d      rd	|z   |d<   d
|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_contentr   str
startswith)selfrequestresponseaecompressed_contentetags         Y/var/www/html/ranktracker/api/venv/lib/python3.12/site-packages/django/middleware/gzip.pyprocess_responsezGZipMiddleware.process_response   s$   !!c(*:*:&;c&AO 12O8%9:\\4b9%%b)O *;8;U;U)VH&)* "11A1A!B%&#h.>.>*??1H),S1A1A-B)CH%&
 ||F#DOOC(#d{HV'-#$    N)__name__
__module____qualname____doc__r#    r$   r"   r	   r	   	   s    
$r$   r	   N)django.utils.cacher   django.utils.deprecationr   django.utils.regex_helperr   django.utils.textr   r   r   r	   r)   r$   r"   <module>r.      s'    1 4 6 @";/*_ *r$   