Ticket #10627: gzip.py.diff

File gzip.py.diff, 1.2 KB (added by FunkyBob, 16 years ago)

Fix for django/middleware/gzip.py

  • gzip.py

     
    1212    on the Accept-Encoding header.
    1313    """
    1414    def process_response(self, request, response):
     15        # Avoid gzipping if we've already got a content-encoding.
     16        # NOTE : The docs mention this as something that will prevent compression.
     17        # However, they don't mention the len() test below, which will gobble generators.
     18        # Putting this first gives less surprise
     19        if response.has_header('Content-Encoding'):
     20            return response
     21
    1522        # It's not worth compressing non-OK or really short responses.
    1623        if response.status_code != 200 or len(response.content) < 200:
    1724            return response
    1825
    1926        patch_vary_headers(response, ('Accept-Encoding',))
    2027
    21         # Avoid gzipping if we've already got a content-encoding.
    22         if response.has_header('Content-Encoding'):
    23             return response
    24 
    2528        # Older versions of IE have issues with gzipped pages containing either
    2629        # Javascript and PDF.
    2730        if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():
Back to Top