internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow)
{
CookieCollection cookies = new CookieCollection();
CookieVariant unknown = CookieVariant.Unknown;
if (headerName == null)
{
unknown = CookieVariant.Rfc2109;
}
else
{
for (int i = 0; i < HeaderInfo.Length; i++)
{
if (string.Compare(headerName, HeaderInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0)
{
unknown = HeaderInfo[i].Variant;
}
}
}
bool isLocalDomain = this.IsLocalDomain(uri.Host);
try
{
Cookie cookie;
CookieParser parser = new CookieParser(setCookieHeader);
Label_0060:
cookie = parser.Get();
if (cookie != null)
{
if (ValidationHelper.IsBlankString(cookie.Name))
{
if (isThrow)
{
throw new CookieException(SR.GetString("net_cookie_format"));
}
}
else if (cookie.VerifySetDefaults(unknown, uri, isLocalDomain, this.m_fqdnMyDomain, true, isThrow))
{
cookies.InternalAdd(cookie, true);
}
goto Label_0060;
}
}
catch (Exception exception)
{
if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException))
{
throw;
}
if (isThrow)
{
throw new CookieException(SR.GetString("net_cookie_parse_header", new object[] { uri.AbsoluteUri }), exception);
}
}
foreach (Cookie cookie2 in cookies)
{
this.Add(cookie2, isThrow);
}
return(cookies);
}