Decrement remainingStreamingBytes before dataHandler calls; simplify isLast check#1918
Draft
Decrement remainingStreamingBytes before dataHandler calls; simplify isLast check#1918
Conversation
- For content-length: decrement remainingStreamingBytes before calling dataHandler so maxRemainingBodyLength() within onData excludes current chunk - For chunked encoding: set remainingStreamingBytes=0 before calling dataHandler with the last (empty) chunk, restore state after so ChunkIterator can properly drop trailing CRLF bytes Ensures isLast == (maxRemainingBodyLength() == 0) for both transfer modes. Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix remainingStreamingBytes decrement before dataHandler calls
Decrement remainingStreamingBytes before dataHandler calls
Mar 20, 2026
…riable Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Agent-Logs-Url: https://github.com/uNetworking/uWebSockets/sessions/7ac360f2-a931-4011-946c-10163706a39d
Copilot
AI
changed the title
Decrement remainingStreamingBytes before dataHandler calls
Decrement remainingStreamingBytes before dataHandler calls; simplify isLast check
Mar 20, 2026
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.
maxRemainingBodyLength()insideonDatacallbacks returned the byte count including the current chunk, breaking the invariantisLast == (maxRemainingBodyLength() == 0)for both content-length and chunked transfers.Changes
Content-length: Decrement
remainingStreamingBytesbefore callingdataHandler(was after), then passremainingStreamingBytes == 0directly asisLast— no local variable needed.Chunked encoding: For the terminal empty chunk, temporarily set
remainingStreamingBytes = 0before callingdataHandler, then restore the saved state soChunkIteratorcan still drop the trailing CRLF on its next step.Applied consistently across all three call sites:
fenceAndConsumePostPadded, the direct path inconsumePostPadded, and the fallback path inconsumePostPadded.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.