Index: gzip.py
===================================================================
--- gzip.py	(revision 10173)
+++ gzip.py	(working copy)
@@ -12,16 +12,19 @@
     on the Accept-Encoding header.
     """
     def process_response(self, request, response):
+        # Avoid gzipping if we've already got a content-encoding.
+        # NOTE : The docs mention this as something that will prevent compression.
+        # However, they don't mention the len() test below, which will gobble generators.
+        # Putting this first gives less surprise
+        if response.has_header('Content-Encoding'):
+            return response
+
         # It's not worth compressing non-OK or really short responses.
         if response.status_code != 200 or len(response.content) < 200:
             return response
 
         patch_vary_headers(response, ('Accept-Encoding',))
 
-        # 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 pages containing either
         # Javascript and PDF.
         if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():
