Fixed #36656 -- Avoided truncating async streaming responses in GZipMiddleware.
Some checks are pending
Linters / flake8 (push) Waiting to run
Linters / isort (push) Waiting to run
Linters / black (push) Waiting to run
Tests / Windows, SQLite, Python 3.14 (push) Waiting to run
Tests / JavaScript tests (push) Waiting to run

This commit is contained in:
Adam Johnson 2025-10-11 00:10:35 +01:00 committed by Jacob Walls
parent 9bb83925d6
commit a0323a0c44
3 changed files with 24 additions and 15 deletions

View file

@ -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):