From 04e829200903bb31a0537b97eb83bd9222ae4ffb Mon Sep 17 00:00:00 2001 From: Quinten Mennen Date: Wed, 24 Sep 2025 13:00:02 +0200 Subject: [PATCH] fix(headers): better content-length evaluation --- webserv/http/HttpRequest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webserv/http/HttpRequest.cpp b/webserv/http/HttpRequest.cpp index f6efb31..1563f3e 100644 --- a/webserv/http/HttpRequest.cpp +++ b/webserv/http/HttpRequest.cpp @@ -129,7 +129,7 @@ bool HttpRequest::parseBufferforHeaders() buffer_.erase(0, pos + Http::Protocol::DOUBLE_CRLF.size()); // parseContentLength(); - if (this->headers_.getContentLength() > 0) + if (this->headers_.getContentLength().value_or(0) > 0) { state_ = State::Body; return true; @@ -192,7 +192,7 @@ bool HttpRequest::parseBufferforBody() state_ = State::Complete; return true; } - Log::trace(LOCATION); + Log::trace(LOCATION, {{"Content-Length", std::to_string(*headers_.getContentLength())}}); if (buffer_.size() < *headers_.getContentLength()) { Log::debug("Body waiting for more data: " + LOCATION);