From: dirkf Date: Fri, 28 Jul 2023 05:03:14 +0000 (+0100) Subject: [utils] Rework decoding of `Content-Encoding`s X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=e7926ae9f4e5fa258696551a39295402819280c9;p=youtube-dl [utils] Rework decoding of `Content-Encoding`s * support nested encodings * support optional `br` encoding, if brotli package is installed * support optional 'compress' encoding, if ncompress package is installed * response `Content-Encoding` has only unprocessed encodings, or removed * response `Content-Length` is decoded length (usable for filesize metadata) * use zlib for both deflate and gzip decompression * some elements taken from yt-dlp: thx especially coletdjnz --- diff --git a/test/test_http.py b/test/test_http.py index 89580969d..793bea359 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -461,33 +461,23 @@ class TestHTTP(unittest.TestCase): sanitized_Request( self._test_url('content-encoding'), headers={'ytdl-encoding': encoding})) - self.assertEqual(res.headers.get('Content-Encoding'), encoding) + # decoded encodings are removed: only check for valid decompressed data self.assertEqual(res.read(), b'