feat: add HTTP/1.1 request serializer - #12
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34e6d4b422
ℹ️ 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".
|
|
||
| if (ascii_iequals(field.name, "Host")) { | ||
| ++host_count; | ||
| if (field.value.empty()) { |
There was a problem hiding this comment.
Reject whitespace-only Host values
When the caller supplies a whitespace-only Host value such as "\t", valid_header_value accepts the tab and this raw emptiness check passes. Serialization then succeeds with a semantically empty Host header while suppressing generation from the URL, producing an invalid HTTP/1.1 request that servers can reject. Check for an empty value after removing optional whitespace, or fully validate the Host authority.
Useful? React with 👍 / 👎.
Summary
Adds the internal HTTP/1.1 request serializer on top of the merged
Request,Headers, andUrldata model.Added
src/http/request_serializer.hppSerializedRequestwith parsedUrl, owned header block, and borrowed body viewsrc/http/request_serializer.cppHTTP/1.1Hostwhen absentHostHostContent-Lengthfor non-empty bodies when absentContent-Lengthagainst body sizeHost/Content-LengthTransfer-Encodingbecause v1 request chunking is out of scopetests/request_serializer_test.cppSerialization model
The serializer intentionally produces two output segments: an owned request head and the original borrowed request body. Future
Clientexecution can therefore callwrite_all(head)followed bywrite_all(body)without allocating a second full request buffer.Scope
This PR does not write bytes to a socket, parse responses, implement redirects, or add
Client. The next step can build the incremental HTTP/1.1 response parser on top ofTcpConnection::read_some().