System.Net.CookieContainer.CookieContainer.Cook C# (CSharp) Method

Cook() public method

public Cook ( Uri uri, Cookie cookie ) : void
uri System.Uri
cookie Cookie
return void
		void Cook (Uri uri, Cookie cookie)
		{
			if (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 && 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 () + "\"";
			}
		}