private void BuildCookieCollectionFromDomainMatches(Uri uri, bool isSecure, int port, CookieCollection cookies, List <string> domainAttribute, bool matchOnlyPlainCookie)
{
for (int i = 0; i < domainAttribute.Count; i++)
{
bool found = false;
bool defaultAdded = false;
PathList pathList;
lock (m_domainTable.SyncRoot) {
pathList = (PathList)m_domainTable[domainAttribute[i]];
}
if (pathList == null)
{
continue;
}
lock (pathList.SyncRoot) {
foreach (DictionaryEntry entry in pathList)
{
string path = (string)entry.Key;
if (uri.AbsolutePath.StartsWith(CookieParser.CheckQuoted(path)))
{
found = true;
CookieCollection cc = (CookieCollection)entry.Value;
cc.TimeStamp(CookieCollection.Stamp.Set);
MergeUpdateCollections(cookies, cc, port, isSecure, matchOnlyPlainCookie);
if (path == "/")
{
defaultAdded = true;
}
}
else if (found)
{
break;
}
}
}
if (!defaultAdded)
{
CookieCollection cc = (CookieCollection)pathList["/"];
if (cc != null)
{
cc.TimeStamp(CookieCollection.Stamp.Set);
MergeUpdateCollections(cookies, cc, port, isSecure, matchOnlyPlainCookie);
}
}
// Remove unused domain
// (This is the only place that does domain removal)
if (pathList.Count == 0)
{
AddRemoveDomain(domainAttribute[i], null);
}
}
}