fix: add max_length support to Gzip/Brotli decoders for urllib3 2.6+#495
Open
CalNightingale wants to merge 1 commit intogoogleapis:mainfrom
Open
fix: add max_length support to Gzip/Brotli decoders for urllib3 2.6+#495CalNightingale wants to merge 1 commit intogoogleapis:mainfrom
CalNightingale wants to merge 1 commit intogoogleapis:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…compatibility urllib3 2.6+ passes max_length to decoder.decompress(). Update _GzipDecoder and _BrotliDecoder to accept and forward max_length, with a TypeError fallback for older urllib3. Add has_unconsumed_tail property to _BrotliDecoder (the proxy class that needs it; _GzipDecoder inherits it from the parent). Fixes googleapis#491
11c51a5 to
2aa67b2
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 #491. Supersedes #492 (stale).
urllib3 >= 2.6.0now passesmax_lengthtodecoder.decompress()and accessesdecoder.has_unconsumed_tail. Our custom_GzipDecoderand_BrotliDecoderwrappers didn't accept these, causingTypeErrorat runtime.This PR:
_GzipDecoder.decompressand_BrotliDecoder.decompressto accept and forwardmax_length, with aTypeErrorfallback for older urllib3has_unconsumed_tailproperty to_BrotliDecoder(the proxy class that needs it explicitly)_GzipDecoderingoogle/_async_resumable_media/max_lengthforwarding, the fallback path, andhas_unconsumed_tailFeedback from #492 addressed
max_length=-1default (chandra-siri) — uses-1to match urllib3's default, notNonehas_unconsumed_tailonly on_BrotliDecoder(chandra-siri) —_GzipDecoderinherits this from the parenturllib3.response.GzipDecoder, so no override is neededmax_lengthforwarding,TypeErrorfallback, andhas_unconsumed_tail(withAttributeErrorfallback for older urllib3)Test plan
pytest tests/unit/requests/test_download.py— all passpytest tests_async/unit/requests/test_download.py— all pass🤖 Generated with Claude Code