Ticket #10627: gzip.py.diff
File gzip.py.diff, 1.2 KB (added by , 16 years ago) |
---|
-
gzip.py
12 12 on the Accept-Encoding header. 13 13 """ 14 14 def process_response(self, request, response): 15 # Avoid gzipping if we've already got a content-encoding. 16 # NOTE : The docs mention this as something that will prevent compression. 17 # However, they don't mention the len() test below, which will gobble generators. 18 # Putting this first gives less surprise 19 if response.has_header('Content-Encoding'): 20 return response 21 15 22 # It's not worth compressing non-OK or really short responses. 16 23 if response.status_code != 200 or len(response.content) < 200: 17 24 return response 18 25 19 26 patch_vary_headers(response, ('Accept-Encoding',)) 20 27 21 # Avoid gzipping if we've already got a content-encoding.22 if response.has_header('Content-Encoding'):23 return response24 25 28 # Older versions of IE have issues with gzipped pages containing either 26 29 # Javascript and PDF. 27 30 if "msie" in request.META.get('HTTP_USER_AGENT', '').lower():