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):
|
22 | 22 | if response.has_header('Content-Encoding'): |
23 | 23 | return response |
24 | 24 | |
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 |
31 | 32 | |
32 | 33 | ae = request.META.get('HTTP_ACCEPT_ENCODING', '') |
33 | 34 | if not re_accepts_gzip.search(ae): |