http: reuse HTTPHeaders to parse chunked trailer

Chunked transfer trailers are just headers that are included
at the end of the request. We can parse and validate them with code
we already use to read headers. In a future commit we will also
be able to use one MAX_HEADERS_SIZE limit to cover both sections.

Even though we parse and validate, we ignore these data.
This commit is contained in:
Matthew Zipkin
2026-07-23 12:38:12 -04:00
parent 902d8908c9
commit 507e528e84
3 changed files with 15 additions and 20 deletions

View File

@@ -104,13 +104,15 @@ public:
*/
void RemoveAll(std::string_view key);
/**
* @param[in] reader A LineReader instance initialized with the client's receive buffer.
* @param[in] write Whether or not to write the parsed data to the object after validation.
* @returns false if LineReader hits the end of the buffer before reading an
* \n, meaning that we are still waiting on more data from the client.
* true after reading an entire HTTP headers section, terminated
* by an empty line and \n.
* @throws on exceeded read limit and on bad headers syntax (e.g. no ":" in a line)
*/
bool Read(util::LineReader& reader);
bool Read(util::LineReader& reader, bool write = true);
std::string Stringify() const;
private: