Ticket #8034: gzip_middleware_no_images.diff
File gzip_middleware_no_images.diff, 792 bytes (added by , 16 years ago) |
---|
-
middleware/gzip.py
4 4 from django.utils.cache import patch_vary_headers 5 5 6 6 re_accepts_gzip = re.compile(r'\bgzip\b') 7 NO_GZIP = re.compile(r'image') 7 8 8 9 class GZipMiddleware(object): 9 10 """ … … 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 NO_GZIP.match(ctype): 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