public void SetCookie(Cookie cookie)
{
if (cookie == null)
{
throw new ArgumentNullException(nameof(cookie));
}
bool added = false;
try
{
Cookies.Add(cookie);
added = true;
}
catch (CookieException)
{
Debug.Assert(!added);
}
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"cookie: {cookie}");
if (!added)
{
// cookie already existed and couldn't be replaced
throw new ArgumentException(SR.net_cookie_exists, nameof(cookie));
}
}