diff options
| author | Adam Johnson <me@adamj.eu> | 2025-10-11 00:10:35 +0100 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-10-21 10:45:12 -0400 |
| commit | a0323a0c44135c28134672e6e633e5f4a7a68d5d (patch) | |
| tree | 8897abf89af92589f84c8dfe5f907f37d503b580 /tests/middleware | |
| parent | 9bb83925d6c231e964f8b54efbc982fb1333da27 (diff) | |
Fixed #36656 -- Avoided truncating async streaming responses in GZipMiddleware.
Diffstat (limited to 'tests/middleware')
| -rw-r--r-- | tests/middleware/tests.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index c4aac0552b..a61c4b147f 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -2,6 +2,7 @@ import gzip import random import re import struct +import zlib from io import BytesIO from unittest import mock from urllib.parse import quote @@ -880,8 +881,8 @@ class GZipMiddlewareTest(SimpleTestCase): @staticmethod def decompress(gzipped_string): - with gzip.GzipFile(mode="rb", fileobj=BytesIO(gzipped_string)) as f: - return f.read() + # Use zlib to ensure gzipped_string contains exactly one gzip stream. + return zlib.decompress(gzipped_string, zlib.MAX_WBITS | 16) @staticmethod def get_mtime(gzipped_string): |
