BNetworkCookieJar::UrlIterator::UrlIterator(const BNetworkCookieJar* cookieJar, const BUrl& url) : fCookieJar(const_cast<BNetworkCookieJar*>(cookieJar)), fIterator(NULL), fList(NULL), fLastList(NULL), fElement(NULL), fLastElement(NULL), fIndex(0), fLastIndex(0), fUrl(url) { BString domain = url.Host(); if (!domain.Length()) return; fIterator = new(std::nothrow) PrivateIterator( fCookieJar->fCookieHashMap->fHashMap.GetIterator()); if (fIterator != NULL) { // Prepending a dot since _FindNext is going to call _SupDomain() domain.Prepend("."); fIterator->fKey.SetTo(domain, domain.Length()); _FindNext(); } }
void BUrlContext::AddAuthentication(const BUrl& url, BHttpAuthentication* const authentication) { BString domain = url.Host(); domain += url.Path(); BPrivate::HashString hostHash(domain.String(), domain.Length()); BHttpAuthentication* previous = fAuthenticationMap->Get(hostHash); // Make sure we don't leak memory by overriding a previous // authentication for the same domain. if(authentication != previous) { fAuthenticationMap->Put(hostHash, authentication); // replaces the old one delete previous; } }