Ticket #6480: 0005-Don-t-gzip-PDF-files-for-IE.patch

File 0005-Don-t-gzip-PDF-files-for-IE.patch, 1.5 KB (added by Bastian Kleineidam <calvin@…>, 17 years ago)
  • django/middleware/gzip.py

    From b908d36e89b560f6e2ba96da93e9c7f3f71778c2 Mon Sep 17 00:00:00 2001
    From: Bastian Kleineidam <calvin@debian.org>
    Date: Fri, 25 Jan 2008 15:38:10 +0100
    Subject: Don't gzip PDF files for IE
    
    Older IE browsers cannot open PDF files with Content-Encoding: gzip.
    This patch prevents gzip encoding for PDF files.
    
    Signed-off-by: Bastian Kleineidam <calvin@debian.org>
    
    diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py
    index 62a2456..805704b 100644
    a b class GZipMiddleware(object):  
    2222        if response.has_header('Content-Encoding'):
    2323            return response
    2424
    25         # Older versions of IE have issues with gzipped javascript.
    26         # See http://code.djangoproject.com/ticket/2449
    27         is_ie = "msie" in request.META.get('HTTP_USER_AGENT', '').lower()
    28         is_js = "javascript" in response.get('Content-Type', '').lower()
    29         if is_ie and is_js:
    30             return response
     25        # Older versions of IE have issues with gzipped pages of certain type,
     26        # eg. javascript and PDF (perhaps more, who knows).
     27        # See also http://code.djangoproject.com/ticket/2449
     28        if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():
     29            ctype = response.get('Content-Type', '').lower()
     30            if "javascript" in ctype or ctype == "application/pdf":
     31                return response
    3132
    3233        ae = request.META.get('HTTP_ACCEPT_ENCODING', '')
    3334        if not re_accepts_gzip.search(ae):
Back to Top