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.
This commit is contained in:
@@ -871,11 +871,17 @@ BHttpRequest::_AddHeaders()
|
|||||||
// Context cookies
|
// Context cookies
|
||||||
if (fOptSetCookies && (fContext != NULL)) {
|
if (fOptSetCookies && (fContext != NULL)) {
|
||||||
BNetworkCookie* cookie;
|
BNetworkCookie* cookie;
|
||||||
|
BString cookieString;
|
||||||
|
|
||||||
for (BNetworkCookieJar::UrlIterator it
|
for (BNetworkCookieJar::UrlIterator it
|
||||||
= fContext->GetCookieJar().GetUrlIterator(fUrl);
|
= fContext->GetCookieJar().GetUrlIterator(fUrl);
|
||||||
(cookie = it.Next()) != NULL;)
|
(cookie = it.Next()) != NULL;) {
|
||||||
fOutputHeaders.AddHeader("Cookie", cookie->RawCookie(false));
|
cookieString << cookie->RawCookie(false);
|
||||||
|
cookieString << "; ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cookieString.length() > 0)
|
||||||
|
fOutputHeaders.AddHeader("Cookie", cookieString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write output headers to output stream
|
// Write output headers to output stream
|
||||||
|
|||||||
Reference in New Issue
Block a user