1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Network: Make Linux networking code robust against user headers that already end with CRLF

This commit is contained in:
reuk 2025-06-16 15:48:58 +01:00
parent 58fabf3a8f
commit b8e0146a3c
No known key found for this signature in database

View file

@ -537,7 +537,16 @@ private:
if (userHeaders.isNotEmpty())
header << "\r\n" << userHeaders;
header << "\r\n\r\n";
const auto headerHasCompleteSuffix = [&header]
{
const auto actualEnd = static_cast<const char*> (header.getData()) + header.getDataSize();
const auto actualBegin = actualEnd - jmin (header.getDataSize(), (size_t) 4);
const char expected[] { '\r', '\n', '\r', '\n' };
return std::equal (actualBegin, actualEnd, std::begin (expected), std::end (expected));
};
while (! headerHasCompleteSuffix())
header << "\r\n";
if (hasPostData)
header << postData;