Repository navigation
Conversation
Keep the start-of-chunk flag until the first payload event is emitted, so network fragmentation does not lose the documented chunk_start marker. Cover both peer roles, extended headers, repeated polls and split payloads. AI-assisted-by: OpenAI Codex
AryanRG
marked this pull request as ready for review
October 16, 2026 22:37
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.
When a chunk header arrives without any payload bytes,
ChunkedReaderconsumes the header and returnsNEED_DATA. Its localchunk_startflag is then lost, so the first payload event haschunk_start=Falsewhen the bytes arrive later. This affects both requests and responses and violates the documented chunk-boundary contract.For example, receiving
5\r\n, polling, then receivinghellocurrently producesData(..., chunk_start=False, chunk_end=True). Receiving those bytes together produceschunk_start=True.Keep the start marker in the reader until it emits the first payload event. Subsequent payload events clear it as before. This leaves framing, syntax validation and payload bytes unchanged.
Four regression cases cover both peer roles, ordinary and extended chunk headers delivered byte by byte, repeated polls without payload, a split payload, and a subsequent complete chunk. All four fail on upstream and pass with the fix. Includes a numbered towncrier release note.
Validation on CPython 3.12.15:
git diff --check: passed.AI assistance was used to prepare the implementation and regression tests.