Django

Code

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@debian.org>, 1 year ago)
  • a/django/middleware/gzip.py

    old new  
    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):