Author: gwilson
Date: 2007-11-18 21:41:46 -0600 (Sun, 18 Nov 2007)
New Revision: 6697

Modified:
   django/trunk/django/middleware/gzip.py
Log:
Made some stylistic changes in `GZipMiddleware` and added some notes about IE, 
refs #5313.


Modified: django/trunk/django/middleware/gzip.py
===================================================================
--- django/trunk/django/middleware/gzip.py      2007-11-19 03:12:19 UTC (rev 
6696)
+++ django/trunk/django/middleware/gzip.py      2007-11-19 03:41:46 UTC (rev 
6697)
@@ -1,4 +1,5 @@
 import re
+
 from django.utils.text import compress_string
 from django.utils.cache import patch_vary_headers
 
@@ -11,20 +12,23 @@
     on the Accept-Encoding header.
     """
     def process_response(self, request, response):
+        # It's not worth compressing non-OK or really short responses.
         if response.status_code != 200 or len(response.content) < 200:
-            # Not worth compressing really short responses or 304 status
-            # responses, etc.
             return response
 
         patch_vary_headers(response, ('Accept-Encoding',))
 
-        # Avoid gzipping if we've already got a content-encoding or if the
-        # content-type is Javascript and the user's browser is IE.
-        is_js = ("msie" in request.META.get('HTTP_USER_AGENT', '').lower() and
-                "javascript" in response.get('Content-Type', '').lower())
-        if response.has_header('Content-Encoding') or is_js:
+        # Avoid gzipping if we've already got a content-encoding.
+        if response.has_header('Content-Encoding'):
             return response
 
+        # Older versions of IE have issues with gzipped javascript.
+        # See http://code.djangoproject.com/ticket/2449
+        is_ie = "msie" in request.META.get('HTTP_USER_AGENT', '').lower()
+        is_js = "javascript" in response.get('Content-Type', '').lower()
+        if is_ie and is_js:
+            return response
+
         ae = request.META.get('HTTP_ACCEPT_ENCODING', '')
         if not re_accepts_gzip.search(ae):
             return response


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to