Repository navigation
feat: add HTTP/1.1 chunked transfer decoder - #14
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 364345a15f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const std::size_t semicolon = line.find(';'); | ||
| const std::string_view size_text = line.substr(0, semicolon); |
There was a problem hiding this comment.
Strip BWS before parsing an extended chunk size
When a server sends a chunk line such as 4 ;foo=bar\r\n, the HTTP chunk-extension grammar permits the whitespace before ; as BWS and requires recipients to tolerate it, but size_text remains "4 ", so from_chars rejects an otherwise parseable response as InvalidChunkSize. Remove the permitted trailing BWS from the size portion before parsing it.
Useful? React with 👍 / 👎.
| for (const unsigned char ch : extension) { | ||
| if (ch == '\t') { | ||
| continue; | ||
| } | ||
| if (ch < 0x20 || ch == 0x7f) { |
There was a problem hiding this comment.
Reject syntactically invalid chunk extensions
When a malformed peer sends an extension such as 4;\r\n or 4;foo="unterminated\r\n, this validator accepts it because it only rejects control bytes, and the response completes successfully. Chunk extensions require a nonempty token name and, when present, a token or valid quoted-string value, so the decoder needs to validate that grammar to satisfy its malformed-framing error contract.
Useful? React with 👍 / 👎.
Summary
Completes HTTP/1.1 response body framing for
Transfer-Encoding: chunkedand integrates it directly into the incremental response parser.Added
src/http/chunked_decoder.hpp/.cppResponseParserintegrationTransfer-Encoding: chunkedis decoded internally instead of returning a handoff stateNeedMoreorCompleteResponsebodyUnexpectedEofResponseParserchunked integrationTrailer policy
Trailer fields are syntax-validated and consumed so message completion is unambiguous, but they are not merged into
Response::headers()in v1. Framing-critical trailer fields such asContent-LengthandTransfer-Encodingare rejected.Scope
This PR completes the v1 response framing primitives for
Content-Length, close-delimited, no-body, and chunked responses. It still does not add socket orchestration, redirects, or the publicClientexecution path.