diff options
author | Bert JW Regeer <xistence@0x58.com> | 2020-12-09 23:05:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 23:05:24 -0800 |
commit | 259230aa2b8b9cf675c996e157c5cf021c256059 (patch) | |
tree | cddc44ce36d490c2ca66185b3847bda8b7121e9b /src | |
parent | 536df8686cc815f0e0ed22e6a7402b83dbec5a00 (diff) | |
parent | cbaa5fa864c0e8f15ba079124a4c42565601200c (diff) | |
download | webob-master.tar.gz |
Merge pull request #424 from d70-t/deflate_with_zlib_containermaster
deflate'd response: use RFC compliant decompression by default
Diffstat (limited to 'src')
-rw-r--r-- | src/webob/response.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/webob/response.py b/src/webob/response.py index e02de87..51d6c89 100644 --- a/src/webob/response.py +++ b/src/webob/response.py @@ -1322,8 +1322,15 @@ class Response: self.content_encoding = None gzip_f.close() else: - # Weird feature: http://bugs.python.org/issue5784 - self.body = zlib.decompress(self.body, -15) + try: + # RFC7230 section 4.2.2 specifies that the body should be wrapped + # inside a ZLIB (RFC1950) container ... + self.body = zlib.decompress(self.body) + except zlib.error: + # ... but there are nonconformant implementations around which send + # the data without the ZLIB container, so we use maximum window size + # decompression without header check (the - sign) + self.body = zlib.decompress(self.body, -15) self.content_encoding = None def md5_etag(self, body=None, set_content_md5=False): |