
    (\iB
                     b    d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	  ed      Z
 G d de      Zy)	    )patch_vary_headers)MiddlewareMixin)_lazy_re_compile)acompress_sequencecompress_sequencecompress_stringz\bgzip\bc                       e Zd 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.
    d   c                 R   |j                   st        |j                        dk  r|S |j                  d      r|S t	        |d       |j
                  j                  dd      }t        j                  |      s|S |j                   rg|j                  r't        |j                  | j                        |_        n&t        |j                  | j                        |_        |j                  d= nvt        |j                  | j                        }t        |      t        |j                        k\  r|S ||_        t!        t        |j                              |j                  d<   |j                  d      }|r#|j#                  d	      rd
|z   |j                  d<   d|j                  d<   |S )N   zContent-Encoding)zAccept-EncodingHTTP_ACCEPT_ENCODING )max_random_byteszContent-LengthETag"zW/gzip)	streaminglencontent
has_headerr   METAgetre_accepts_gzipsearchis_asyncr   streaming_contentr   r   headersr   str
startswith)selfrequestresponseaecompressed_contentetags         f/home/devuser/fomin/mqttuser/mqtt_project/myenv/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  -?..%)%:%:.*
 .?..%)%:%:.*   !12 "1  !%!6!6" %&#h.>.>*??1H14S9I9I5J1KH-.
 ||F#DOOC('+d{HV$/5+,    N)__name__
__module____qualname____doc__r   r(    r)   r'   r
   r
   	   s     0r)   r
   N)django.utils.cacher   django.utils.deprecationr   django.utils.regex_helperr   django.utils.textr   r   r   r   r
   r.   r)   r'   <module>r3      s*    1 4 6 T T";/9_ 9r)   