fix(headers): better content-length evaluation

This commit is contained in:
Quinten Mennen 2025-09-24 13:00:02 +02:00
parent ba831957d4
commit 04e8292009

View File

@ -129,7 +129,7 @@ bool HttpRequest::parseBufferforHeaders()
buffer_.erase(0, pos + Http::Protocol::DOUBLE_CRLF.size()); buffer_.erase(0, pos + Http::Protocol::DOUBLE_CRLF.size());
// parseContentLength(); // parseContentLength();
if (this->headers_.getContentLength() > 0) if (this->headers_.getContentLength().value_or(0) > 0)
{ {
state_ = State::Body; state_ = State::Body;
return true; return true;
@ -192,7 +192,7 @@ bool HttpRequest::parseBufferforBody()
state_ = State::Complete; state_ = State::Complete;
return true; return true;
} }
Log::trace(LOCATION); Log::trace(LOCATION, {{"Content-Length", std::to_string(*headers_.getContentLength())}});
if (buffer_.size() < *headers_.getContentLength()) if (buffer_.size() < *headers_.getContentLength())
{ {
Log::debug("Body waiting for more data: " + LOCATION); Log::debug("Body waiting for more data: " + LOCATION);