Ñò
ŸjáIc           @   sU   d  d k  Z  d  d k l Z d  d k l Z e  i d ƒ Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   compress_string(   t   patch_vary_headerss   \bgzip\bt   GZipMiddlewarec           B   s   e  Z d  Z d „  Z RS(   sÇ   
    This middleware compresses content if the browser allows gzip compression.
    It sets the Vary header accordingly, so that caches will base their storage
    on the Accept-Encoding header.
    c         C   s  | i  d j p t | i ƒ d j  o | St | d ƒ | i d ƒ o | Sd | i i d d ƒ i ƒ  j o? | i d d ƒ i ƒ  } | i d ƒ p d	 | j o | Sn | i i d
 d ƒ } t	 i
 | ƒ p | St | i ƒ | _ d | d <t t | i ƒ ƒ | d <| S(   NiÈ   s   Accept-Encodings   Content-Encodingt   msiet   HTTP_USER_AGENTt    s   Content-Types   text/t
   javascriptt   HTTP_ACCEPT_ENCODINGt   gzips   Content-Length(   s   Accept-Encoding(   t   status_codet   lent   contentR   t
   has_headert   METAt   gett   lowert
   startswitht   re_accepts_gzipt   searchR    t   str(   t   selft   requestt   responset   ctypet   ae(    (    s@   /usr/local/lib/python2.6/dist-packages/django/middleware/gzip.pyt   process_response   s     &"	
(   t   __name__t
   __module__t   __doc__R   (    (    (    s@   /usr/local/lib/python2.6/dist-packages/django/middleware/gzip.pyR      s   (	   t   ret   django.utils.textR    t   django.utils.cacheR   t   compileR   t   objectR   (    (    (    s@   /usr/local/lib/python2.6/dist-packages/django/middleware/gzip.pyt   <module>   s   