Accumulate headers properly

This commit is contained in:
2025-08-20 14:10:39 -04:00
parent 8ccb02f450
commit abb47ee0c3
3 changed files with 100 additions and 36 deletions

View File

@@ -41,8 +41,14 @@ struct HttpConnectionState {
bool message_complete = false;
bool connection_close = false; // Client requested connection close
HttpRoute route = HttpRoute::NotFound;
std::string_view current_header_field; // Current header being parsed
uint64_t request_id = 0; // X-Request-Id header value
// Header accumulation buffers (arena-allocated)
using ArenaString =
std::basic_string<char, std::char_traits<char>, ArenaStlAllocator<char>>;
ArenaString current_header_field_buf;
ArenaString current_header_value_buf;
bool header_field_complete = false;
uint64_t request_id = 0; // X-Request-Id header value
explicit HttpConnectionState(ArenaAllocator &arena);
};
@@ -67,7 +73,9 @@ public:
// llhttp callbacks (public for HttpConnectionState access)
static int onUrl(llhttp_t *parser, const char *at, size_t length);
static int onHeaderField(llhttp_t *parser, const char *at, size_t length);
static int onHeaderFieldComplete(llhttp_t *parser);
static int onHeaderValue(llhttp_t *parser, const char *at, size_t length);
static int onHeaderValueComplete(llhttp_t *parser);
static int onHeadersComplete(llhttp_t *parser);
static int onBody(llhttp_t *parser, const char *at, size_t length);
static int onMessageComplete(llhttp_t *parser);