From f9d987ae68a6355b123ce9f9b4f96f772fab2d7d Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 11 Oct 2013 13:33:08 +0200 Subject: [PATCH] HttpRequest: put cookies in a single header entry * Http spec says headers can be split when they are comma separated * However, cookies are semicolon separated, so it is not acceptable to split them. * We will want to implement some way to limit the cookie header entry size, as servers have a limit on what they can accept (usually around 4K characters). The RFC also says we don't need to remember more than 20 cookies per domain. --- src/kits/network/libnetapi/HttpRequest.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kits/network/libnetapi/HttpRequest.cpp b/src/kits/network/libnetapi/HttpRequest.cpp index 0c2a91d8f9..ed6712126e 100644 --- a/src/kits/network/libnetapi/HttpRequest.cpp +++ b/src/kits/network/libnetapi/HttpRequest.cpp @@ -871,11 +871,17 @@ BHttpRequest::_AddHeaders() // Context cookies if (fOptSetCookies && (fContext != NULL)) { BNetworkCookie* cookie; + BString cookieString; for (BNetworkCookieJar::UrlIterator it = fContext->GetCookieJar().GetUrlIterator(fUrl); - (cookie = it.Next()) != NULL;) - fOutputHeaders.AddHeader("Cookie", cookie->RawCookie(false)); + (cookie = it.Next()) != NULL;) { + cookieString << cookie->RawCookie(false); + cookieString << "; "; + } + + if (cookieString.length() > 0) + fOutputHeaders.AddHeader("Cookie", cookieString); } // Write output headers to output stream