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:46:37 -0400 |
| commit | bb4fcf5f67e6a39440bb1271450319604a755f2e (patch) | |
| tree | b26c51a85fbc444b8c4609714f9f5be22735d9b7 /tests | |
| parent | f5b6ed78200b2cbff71ec771e6f014de5d4abbd8 (diff) | |
[6.0.x] Fixed #36656 -- Avoided truncating async streaming responses in GZipMiddleware.
Backport of a0323a0c44135c28134672e6e633e5f4a7a68d5d from main.
Diffstat (limited to 'tests')
| -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): |
