private void Cook(System.Uri uri, Cookie cookie) { if (CookieContainer.IsNullOrEmpty(cookie.Name)) { throw new CookieException("Invalid cookie: name"); } if (cookie.Value == null) { throw new CookieException("Invalid cookie: value"); } if (uri != null && cookie.Domain.Length == 0) { cookie.Domain = uri.Host; } if (cookie.Version == 0 && CookieContainer.IsNullOrEmpty(cookie.Path)) { if (uri != null) { cookie.Path = uri.AbsolutePath; } else { cookie.Path = "/"; } } if (cookie.Port.Length == 0 && uri != null && !uri.IsDefaultPort) { cookie.Port = "\"" + uri.Port.ToString() + "\""; } }