Ticket #8034: gzip_middleware_no_images.2.diff
File gzip_middleware_no_images.2.diff, 796 bytes (added by , 16 years ago) |
---|
-
middleware/gzip.py
(this hunk was shorter than expected) 4 4 from django.utils.cache import patch_vary_headers 5 5 6 6 re_accepts_gzip = re.compile(r'\bgzip\b') 7 7 8 8 class GZipMiddleware(object): 9 9 """ … … 12 13 on the Accept-Encoding header. 13 14 """ 14 15 def process_response(self, request, response): 16 ctype = response.get('Content-Type', '').lower() 17 if ctype and (ctype.startswith('image') or ctype.startswith('video')): 18 return response 19 15 20 # It's not worth compressing non-OK or really short responses. 16 21 if response.status_code != 200 or len(response.content) < 200: 17 22 return response