support different headerseperators

This commit is contained in:
whaffman 2025-10-30 15:06:36 +01:00
parent 334c378d23
commit c2bdbeb307
2 changed files with 10 additions and 2 deletions

@ -1 +1 @@
Subproject commit 6afa83b23a83cfb98034ab432850cb8a660ff222
Subproject commit 9165a63af961a9892e1d716c984328bf4756cd34

View File

@ -161,6 +161,7 @@ void CgiHandler::setPid(int pid)
void CgiHandler::parseCgiOutput()
{
Log::trace(LOCATION);
long headerSeperatorSize = 2;
// Parse the headers from the buffer
auto header = std::string(buffer_.begin(), buffer_.end());
@ -169,18 +170,25 @@ void CgiHandler::parseCgiOutput()
header.find("\n\n"),
header.find("\r\r"),
});
if (headerEnd == std::string::npos)
{
Log::debug("CGI output headers not complete yet");
return;
}
if (header.substr(static_cast<long>(headerEnd), 2) == "\r\n")
{
headerSeperatorSize = 4;
}
Log::debug("headerseperator: " + header.substr(static_cast<long>(headerEnd), 2));
// Parse the headers
std::string headers(buffer_.begin(), buffer_.begin() + static_cast<long>(headerEnd));
Log::debug("CGI output headers: " + headers);
parseCgiHeaders(headers);
buffer_.erase(buffer_.begin(), buffer_.begin() + static_cast<long>(headerEnd) + 4);
buffer_.erase(buffer_.begin(), buffer_.begin() + static_cast<long>(headerEnd) + headerSeperatorSize);
parseCgiBody();
}