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:
parent
58fabf3a8f
commit
b8e0146a3c
1 changed files with 10 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue