From 77f1b8a50d10ca9e393a7cb0d94c662be20e272a Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 31 Jul 2006 21:31:35 +0000 Subject: [PATCH] Fixed #2449 -- gzip middleware no longer gzips Javascript. Thanks for the prob, ubernostrum git-svn-id: http://code.djangoproject.com/svn/django/trunk@3503 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/middleware/gzip.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py index cc8a68406c..7d860abdb1 100644 --- a/django/middleware/gzip.py +++ b/django/middleware/gzip.py @@ -12,7 +12,11 @@ class GZipMiddleware(object): """ def process_response(self, request, response): patch_vary_headers(response, ('Accept-Encoding',)) - if response.has_header('Content-Encoding'): + + # Avoid gzipping if we've already got a content-encoding or if the + # content-type is Javascript (silly IE...) + is_js = "javascript" in response.headers.get('Content-Type', '').lower() + if response.has_header('Content-Encoding') or is_js: return response ae = request.META.get('HTTP_ACCEPT_ENCODING', '')