Repository navigation
Handle empty responses without a content type - #402
Open
blouirts123 wants to merge 1 commit into
Open
blouirts123 wants to merge 1 commit into
blouirts123 wants to merge 1 commit into
Conversation
An empty response can omit Content-Type, causing multipart decoding to fail before callers can inspect its parts. Return an empty tuple only for that exact case, preserving other validation and the encoding. Add regression and behavior-preservation tests and document the case. Closes requests#345.
blouirts123
marked this pull request as draft
October 16, 2026 04:52
blouirts123
marked this pull request as ready for review
October 16, 2026 05:25
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.
Fixes #345. A response with
content == b''and no Content-Type currently raisesAttributeErrorbeforeMultipartDecoder.from_response()can return a decoder.Return an empty
partstuple for that exact case and preserve the supplied encoding. Nonempty bodies without a Content-Type keep their existing behavior, as do explicit invalid content types and empty multipart bodies with a valid boundary. This addresses the empty-response handling requested in #345; #399 covers a different missing-boundary case.Validation: 19 decoder tests pass. Full strict-warning suites pass on Python 3.8–3.11 (171 passed, 5 skipped each) with PyOpenSSL 24.2.1 in the local environments. With the latest resolved PyOpenSSL 26.4.0, both candidate and unchanged base fail the same two X509 adapter tests on dependency deprecation warnings. No dependency pin is added. Ordinary flake8 passes; the docstrings plugin reports the same 171 findings on both trees. The Sphinx HTML build succeeds with one theme deprecation warning. PyPy 2.7.18 also passes all 19 decoder tests using pytest 3.5.1 and compatible legacy dependencies; PyOpenSSL was unavailable there, and its two tests use the existing project skip condition. Its full strict-warning suite reports 167 passed, 7 skipped, and the same two Windows TCP-keepalive strict XPASS failures as the unchanged base (162 passed, 7 skipped, same two failures). Python 3.7 was not run locally.