Ticket #15066: gzip-generators.diff
File gzip-generators.diff, 975 bytes (added by , 14 years ago) |
---|
-
django/middleware/gzip.py
1 1 import re 2 from types import GeneratorType 2 3 3 4 from django.utils.text import compress_string 4 5 from django.utils.cache import patch_vary_headers … … 13 14 """ 14 15 def process_response(self, request, response): 15 16 # It's not worth compressing non-OK or really short responses. 16 if response.status_code != 200 or len(response.content) < 200: 17 # Responses that are streamed using a generator are not supported 18 # here because the content length cannot be determined beforehand. 19 if (response.status_code != 200 or 20 isinstance(response._container, GeneratorType) or 21 len(response.content) < 200): 17 22 return response 18 23 19 24 patch_vary_headers(response, ('Accept-Encoding',))