Alright, I see what the problem is here. When multiple headers are added with the same name they are concatenated into a single header and separated with a new line '\n'. Then the static method QNetworkCookie::parseCookies is supposed to split the cookies up into separate cookies, but that method is broken.
From what I can tell that method thinks that cookies are separated by commas rather than newlines, because I see this case:
case ',':
// end of the cookie
endOfCookie = true;
break;
case ',':
// end of the cookie
endOfCookie = true;
break;
To copy to clipboard, switch view to plain text mode
At first glance it would seem that just changing that ',' to '\n' would fix it, but no. What happens is everytime it encounters a ";" it thinks that a new field of the cookie is going to follow, and it jumps ahead to the next non-whitespace character after that, and starts the name of the next cookie as a new field in this cookie.
It would probably take a refactor of the parseCookies method to fix it correctly along the lines of what they're trying to do, but I found a temporary fix that works, and is probably a better solution anyway.
Near the beginning of this method is this:
int position = 0;
const int length = cookieString.length();
while (position < length) {
int position = 0;
const int length = cookieString.length();
while (position < length) {
To copy to clipboard, switch view to plain text mode
If we change that to this:
QList<QByteArray> cookieStrings = cookieString.split('\n');
{
int position = 0;
const int length = cookieString.length();
QList<QByteArray> cookieStrings = cookieString.split('\n');
foreach( QByteArray cookieString, cookieStrings )
{
int position = 0;
const int length = cookieString.length();
To copy to clipboard, switch view to plain text mode
It will first break the set of cookies up into separate QByteArrays, and then process them individually so it doesn't have to worry about trying to find the separator character each time through.
I'm going to file a bug report after this, but figured I would post it in here in case anybody else runs into this problem.
Cheers
Bookmarks