Skip to content

Revert chunked encoding return semantics to restore parser correctness - #1938

Merged
uNetworkingAB merged 1 commit into
masterfrom
copilot/revert-e7deb72
Aug 29, 2026
Merged

Revert chunked encoding return semantics to restore parser correctness#1938
uNetworkingAB merged 1 commit into
masterfrom
copilot/revert-e7deb72

Conversation

Copilot AI commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The chunked transfer parser was emitting end-of-body markers at the wrong point after a refactor, which altered the terminal-state semantics for chunked and trailer parsing. This restores the prior behavior so the parser continues to signal completion only when the framing state actually reaches the correct end-of-body condition.

  • What changed

    • Reverted the return semantics introduced in e7deb72 in src/ChunkedEncoding.h.
    • Restored the original std::nullopt terminal behavior for the trailer final-empty-line and legacy fallback paths.
    • Preserved the empty-terminated chunk signal only in the legacy state transition where it was intentionally used before the refactor.
  • Why this matters

    • The parser must not report “end of body” prematurely while still inside trailer parsing or while final chunk framing is incomplete.
    • The reverted behavior keeps chunk termination aligned with the HTTP chunked framing rules and avoids false completion during trailer handling.
  • Example

if (c == '\n') {
    state = 0;
    return std::nullopt;  // report completion only when the state is actually terminal
}
  • Impact
    • Restores the parser behavior expected by the surrounding HTTP handling code.
    • Keeps chunked-body termination deterministic across partial-buffer and trailer edge cases.

Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants