UrlProtocolHttp: parse received cookies

* We didn't do anything with cookies received from the server, they are
now automatically added to the cookie jar.
 * Also make sure the UrlContext (which holds the cookie jar) is
forwarded from UrlRequest to UrlProtocol when it gets set.

this gets cookies working in Service Kit-based WebKit.
This commit is contained in:
Adrien Destugues 2013-09-01 19:40:57 +02:00
parent 41e940ca3b
commit a8dd17c9b9
2 changed files with 7 additions and 0 deletions

View File

@ -508,6 +508,10 @@ BUrlProtocolHttp::_MakeRequest()
if ((fContext != NULL) && fHeaders.HasHeader("Set-Cookie")) {
for (int32 i = 0; i < fHeaders.CountHeaders(); i++) {
if (fHeaders.HeaderAt(i).NameIs("Set-Cookie")) {
BNetworkCookie* cookie = new BNetworkCookie();
cookie->ParseCookieStringFromUrl(
fHeaders.HeaderAt(i).Value(), fUrl);
fContext->GetCookieJar().AddCookie(cookie);
}
}
}

View File

@ -69,6 +69,9 @@ void
BUrlRequest::SetContext(BUrlContext* context)
{
fContext = context;
if (fUrlProtocol != NULL)
fUrlProtocol->SetContext(context);
}