Fix GzipDecompressor to handle concatenated gzip members#3577
Open
veeceey wants to merge 1 commit intotornadoweb:masterfrom
Open
Fix GzipDecompressor to handle concatenated gzip members#3577veeceey wants to merge 1 commit intotornadoweb:masterfrom
veeceey wants to merge 1 commit intotornadoweb:masterfrom
Conversation
The GzipDecompressor class now properly handles concatenated gzip members by checking for unused_data after each decompression and creating a new decompressor to continue processing subsequent members. This prevents silent data loss when decompressing multi-member gzip streams. Changes: - Added loop in decompress() to process all concatenated gzip members - Added _flushed flag to prevent decompress() calls after flush() - Added comprehensive test cases for single, double, and triple member streams - Added test to verify RuntimeError after flush() Fixes tornadoweb#3560
e74c3f8 to
c2af718
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3560
The
GzipDecompressorclass now properly handles concatenated gzip members by checking forunused_dataafter each decompression and creating a new decompressor to continue processing subsequent members. This prevents silent data loss when decompressing multi-member gzip streams, which is a common pattern in HTTP streaming and other applications.Changes
GzipDecompressor.decompress()to loop through concatenated gzip members usingunused_data_flushedflag to preventdecompress()calls afterflush()has been calledTest Results
All existing tests pass, and new tests verify the fix:
The reproduction script from the issue now works correctly: