Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed how HTTP headers are ended on Linux #1352

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion modules/juce_core/native/juce_Network_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,14 @@ class WebInputStream::Pimpl
if (userHeaders.isNotEmpty())
header << "\r\n" << userHeaders;

header << "\r\n\r\n";
if(header.toString().endsWith("\r\n"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure there's a better to detect \r\n than creating a string copy here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added another commit which uses a reference to a variable.

Copy link

@aminya aminya Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant was the toString call, which I think creates a string copy. It should not matter much as headers should be small.

The actual string literals were fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header variable is a juce::MemoryOutputStream. I do not know how to check the end of that for the string I am looking for but I would argue that my method of fixing it is better than having the bug present. This breaks our licensing in our application and we have to used a forked version instead.

{
header << "\r\n";
}
else
{
header << "\r\n\r\n";
}

if (hasPostData)
header << postData;
Expand Down