using System; using System.Collections; using System.Globalization; using System.Text; namespace System.Net { /// Provides a set of properties and methods that are used to manage cookies. This class cannot be inherited. // Token: 0x02000205 RID: 517 [Serializable] public sealed class Cookie { /// Initializes a new instance of the class. // Token: 0x0600116E RID: 4462 RVA: 0x00033418 File Offset: 0x00031618 public Cookie() { this.expires = DateTime.MinValue; this.timestamp = DateTime.Now; this.domain = string.Empty; this.name = string.Empty; this.val = string.Empty; this.comment = string.Empty; this.port = string.Empty; } /// Initializes a new instance of the class with a specified and . /// The name of a . The following characters must not be used inside : equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character. /// The value of a . The following characters must not be used inside : semicolon, comma. /// The parameter is null. -or- The parameter is of zero length. -or- The parameter contains an invalid character.-or- The parameter is null .-or - The parameter contains a string not enclosed in quotes that contains an invalid character. // Token: 0x0600116F RID: 4463 RVA: 0x00033478 File Offset: 0x00031678 public Cookie(string name, string value) : this() { this.Name = name; this.Value = value; } /// Initializes a new instance of the class with a specified , , and . /// The name of a . The following characters must not be used inside : equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character. /// The value of a . The following characters must not be used inside : semicolon, comma. /// The subset of URIs on the origin server to which this applies. The default value is "/". /// The parameter is null. -or- The parameter is of zero length. -or- The parameter contains an invalid character.-or- The parameter is null .-or - The parameter contains a string not enclosed in quotes that contains an invalid character. // Token: 0x06001170 RID: 4464 RVA: 0x00033490 File Offset: 0x00031690 public Cookie(string name, string value, string path) : this(name, value) { this.Path = path; } /// Initializes a new instance of the class with a specified , , , and . /// The name of a . The following characters must not be used inside : equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character. /// The value of a object. The following characters must not be used inside : semicolon, comma. /// The subset of URIs on the origin server to which this applies. The default value is "/". /// The optional internet domain for which this is valid. The default value is the host this has been received from. /// The parameter is null. -or- The parameter is of zero length. -or- The parameter contains an invalid character.-or- The parameter is null .-or - The parameter contains a string not enclosed in quotes that contains an invalid character. // Token: 0x06001171 RID: 4465 RVA: 0x000334A4 File Offset: 0x000316A4 public Cookie(string name, string value, string path, string domain) : this(name, value, path) { this.Domain = domain; } /// Gets or sets a comment that the server can add to a . /// An optional comment to document intended usage for this . // Token: 0x170005B8 RID: 1464 // (get) Token: 0x06001173 RID: 4467 RVA: 0x000334F0 File Offset: 0x000316F0 // (set) Token: 0x06001174 RID: 4468 RVA: 0x000334F8 File Offset: 0x000316F8 public string Comment { get { return this.comment; } set { this.comment = ((value != null) ? value : string.Empty); } } /// Gets or sets a URI comment that the server can provide with a . /// An optional comment that represents the intended usage of the URI reference for this . The value must conform to URI format. // Token: 0x170005B9 RID: 1465 // (get) Token: 0x06001175 RID: 4469 RVA: 0x00033514 File Offset: 0x00031714 // (set) Token: 0x06001176 RID: 4470 RVA: 0x0003351C File Offset: 0x0003171C public global::System.Uri CommentUri { get { return this.commentUri; } set { this.commentUri = value; } } /// Gets or sets the discard flag set by the server. /// true if the client is to discard the at the end of the current session; otherwise, false. The default is false. // Token: 0x170005BA RID: 1466 // (get) Token: 0x06001177 RID: 4471 RVA: 0x00033528 File Offset: 0x00031728 // (set) Token: 0x06001178 RID: 4472 RVA: 0x00033530 File Offset: 0x00031730 public bool Discard { get { return this.discard; } set { this.discard = value; } } /// Gets or sets the URI for which the is valid. /// The URI for which the is valid. // Token: 0x170005BB RID: 1467 // (get) Token: 0x06001179 RID: 4473 RVA: 0x0003353C File Offset: 0x0003173C // (set) Token: 0x0600117A RID: 4474 RVA: 0x00033544 File Offset: 0x00031744 public string Domain { get { return this.domain; } set { if (Cookie.IsNullOrEmpty(value)) { this.domain = string.Empty; this.ExactDomain = true; } else { this.domain = value; this.ExactDomain = value[0] != '.'; } } } // Token: 0x170005BC RID: 1468 // (get) Token: 0x0600117B RID: 4475 RVA: 0x00033590 File Offset: 0x00031790 // (set) Token: 0x0600117C RID: 4476 RVA: 0x00033598 File Offset: 0x00031798 internal bool ExactDomain { get { return this.exact_domain; } set { this.exact_domain = value; } } /// Gets or sets the current state of the . /// true if the has expired; otherwise, false. The default is false. // Token: 0x170005BD RID: 1469 // (get) Token: 0x0600117D RID: 4477 RVA: 0x000335A4 File Offset: 0x000317A4 // (set) Token: 0x0600117E RID: 4478 RVA: 0x000335DC File Offset: 0x000317DC public bool Expired { get { return this.expires <= DateTime.Now && this.expires != DateTime.MinValue; } set { if (value) { this.expires = DateTime.Now; } } } /// Gets or sets the expiration date and time for the as a . /// The expiration date and time for the as a instance. // Token: 0x170005BE RID: 1470 // (get) Token: 0x0600117F RID: 4479 RVA: 0x000335F0 File Offset: 0x000317F0 // (set) Token: 0x06001180 RID: 4480 RVA: 0x000335F8 File Offset: 0x000317F8 public DateTime Expires { get { return this.expires; } set { this.expires = value; } } /// Determines whether a page script or other active content can access this cookie. /// Boolean value that determines whether a page script or other active content can access this cookie. // Token: 0x170005BF RID: 1471 // (get) Token: 0x06001181 RID: 4481 RVA: 0x00033604 File Offset: 0x00031804 // (set) Token: 0x06001182 RID: 4482 RVA: 0x0003360C File Offset: 0x0003180C public bool HttpOnly { get { return this.httpOnly; } set { this.httpOnly = value; } } /// Gets or sets the name for the . /// The name for the . /// The value specified for a set operation is null or the empty string- or -The value specified for a set operation contained an illegal character. The following characters must not be used inside the property: equal sign, semicolon, comma, newline (\n), return (\r), tab (\t), and space character. The dollar sign character ("$") cannot be the first character. // Token: 0x170005C0 RID: 1472 // (get) Token: 0x06001183 RID: 4483 RVA: 0x00033618 File Offset: 0x00031818 // (set) Token: 0x06001184 RID: 4484 RVA: 0x00033620 File Offset: 0x00031820 public string Name { get { return this.name; } set { if (Cookie.IsNullOrEmpty(value)) { throw new CookieException("Name cannot be empty"); } if (value[0] == '$' || value.IndexOfAny(Cookie.reservedCharsName) != -1) { this.name = string.Empty; throw new CookieException("Name contains invalid characters"); } this.name = value; } } /// Gets or sets the URIs to which the applies. /// The URIs to which the applies. // Token: 0x170005C1 RID: 1473 // (get) Token: 0x06001185 RID: 4485 RVA: 0x00033680 File Offset: 0x00031880 // (set) Token: 0x06001186 RID: 4486 RVA: 0x000336A0 File Offset: 0x000318A0 public string Path { get { return (this.path != null) ? this.path : string.Empty; } set { this.path = ((value != null) ? value : string.Empty); } } /// Gets or sets a list of TCP ports that the applies to. /// The list of TCP ports that the applies to. /// The value specified for a set operation could not be parsed or is not enclosed in double quotes. // Token: 0x170005C2 RID: 1474 // (get) Token: 0x06001187 RID: 4487 RVA: 0x000336BC File Offset: 0x000318BC // (set) Token: 0x06001188 RID: 4488 RVA: 0x000336C4 File Offset: 0x000318C4 public string Port { get { return this.port; } set { if (Cookie.IsNullOrEmpty(value)) { this.port = string.Empty; return; } if (value[0] != '"' || value[value.Length - 1] != '"') { throw new CookieException("The 'Port'='" + value + "' part of the cookie is invalid. Port must be enclosed by double quotes."); } this.port = value; string[] array = this.port.Split(Cookie.portSeparators); this.ports = new int[array.Length]; for (int i = 0; i < this.ports.Length; i++) { this.ports[i] = int.MinValue; if (array[i].Length != 0) { try { this.ports[i] = int.Parse(array[i]); } catch (Exception ex) { throw new CookieException("The 'Port'='" + value + "' part of the cookie is invalid. Invalid value: " + array[i], ex); } } } this.Version = 1; } } // Token: 0x170005C3 RID: 1475 // (get) Token: 0x06001189 RID: 4489 RVA: 0x000337D8 File Offset: 0x000319D8 internal int[] Ports { get { return this.ports; } } /// Gets or sets the security level of a . /// true if the client is only to return the cookie in subsequent requests if those requests use Secure Hypertext Transfer Protocol (HTTPS); otherwise, false. The default is false. // Token: 0x170005C4 RID: 1476 // (get) Token: 0x0600118A RID: 4490 RVA: 0x000337E0 File Offset: 0x000319E0 // (set) Token: 0x0600118B RID: 4491 RVA: 0x000337E8 File Offset: 0x000319E8 public bool Secure { get { return this.secure; } set { this.secure = value; } } /// Gets the time when the cookie was issued as a . /// The time when the cookie was issued as a . // Token: 0x170005C5 RID: 1477 // (get) Token: 0x0600118C RID: 4492 RVA: 0x000337F4 File Offset: 0x000319F4 public DateTime TimeStamp { get { return this.timestamp; } } /// Gets or sets the for the . /// The for the . // Token: 0x170005C6 RID: 1478 // (get) Token: 0x0600118D RID: 4493 RVA: 0x000337FC File Offset: 0x000319FC // (set) Token: 0x0600118E RID: 4494 RVA: 0x00033804 File Offset: 0x00031A04 public string Value { get { return this.val; } set { if (value == null) { this.val = string.Empty; return; } this.val = value; } } /// Gets or sets the version of HTTP state maintenance to which the cookie conforms. /// The version of HTTP state maintenance to which the cookie conforms. /// The value specified for a version is not allowed. // Token: 0x170005C7 RID: 1479 // (get) Token: 0x0600118F RID: 4495 RVA: 0x00033820 File Offset: 0x00031A20 // (set) Token: 0x06001190 RID: 4496 RVA: 0x00033828 File Offset: 0x00031A28 public int Version { get { return this.version; } set { if (value < 0 || value > 10) { this.version = 0; } else { this.version = value; } } } /// Overrides the method. /// Returns true if the is equal to . Two instances are equal if their , , , , and properties are equal. and string comparisons are case-insensitive. /// A reference to a . // Token: 0x06001191 RID: 4497 RVA: 0x00033858 File Offset: 0x00031A58 public override bool Equals(object obj) { Cookie cookie = obj as Cookie; return cookie != null && string.Compare(this.name, cookie.name, true, CultureInfo.InvariantCulture) == 0 && string.Compare(this.val, cookie.val, false, CultureInfo.InvariantCulture) == 0 && string.Compare(this.Path, cookie.Path, false, CultureInfo.InvariantCulture) == 0 && string.Compare(this.domain, cookie.domain, true, CultureInfo.InvariantCulture) == 0 && this.version == cookie.version; } /// Overrides the method. /// The 32-bit signed integer hash code for this instance. // Token: 0x06001192 RID: 4498 RVA: 0x000338F4 File Offset: 0x00031AF4 public override int GetHashCode() { return Cookie.hash(CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode(this.name), this.val.GetHashCode(), this.Path.GetHashCode(), CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode(this.domain), this.version); } // Token: 0x06001193 RID: 4499 RVA: 0x00033944 File Offset: 0x00031B44 private static int hash(int i, int j, int k, int l, int m) { return i ^ ((j << 13) | (j >> 19)) ^ ((k << 26) | (k >> 6)) ^ ((l << 7) | (l >> 25)) ^ ((m << 20) | (m >> 12)); } /// Overrides the method. /// Returns a string representation of this object that is suitable for including in a HTTP Cookie: request header. /// /// /// // Token: 0x06001194 RID: 4500 RVA: 0x00033970 File Offset: 0x00031B70 public override string ToString() { return this.ToString(null); } // Token: 0x06001195 RID: 4501 RVA: 0x0003397C File Offset: 0x00031B7C internal string ToString(global::System.Uri uri) { if (this.name.Length == 0) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(64); if (this.version > 0) { stringBuilder.Append("$Version=").Append(this.version).Append("; "); } stringBuilder.Append(this.name).Append("=").Append(this.val); if (this.version == 0) { return stringBuilder.ToString(); } if (!Cookie.IsNullOrEmpty(this.path)) { stringBuilder.Append("; $Path=").Append(this.path); } else if (uri != null) { stringBuilder.Append("; $Path=/").Append(this.path); } bool flag = uri == null || uri.Host != this.domain; if (flag && !Cookie.IsNullOrEmpty(this.domain)) { stringBuilder.Append("; $Domain=").Append(this.domain); } if (this.port != null && this.port.Length != 0) { stringBuilder.Append("; $Port=").Append(this.port); } return stringBuilder.ToString(); } // Token: 0x06001196 RID: 4502 RVA: 0x00033AE0 File Offset: 0x00031CE0 internal string ToClientString() { if (this.name.Length == 0) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(64); if (this.version > 0) { stringBuilder.Append("Version=").Append(this.version).Append(";"); } stringBuilder.Append(this.name).Append("=").Append(this.val); if (this.path != null && this.path.Length != 0) { stringBuilder.Append(";Path=").Append(this.QuotedString(this.path)); } if (this.domain != null && this.domain.Length != 0) { stringBuilder.Append(";Domain=").Append(this.QuotedString(this.domain)); } if (this.port != null && this.port.Length != 0) { stringBuilder.Append(";Port=").Append(this.port); } return stringBuilder.ToString(); } // Token: 0x06001197 RID: 4503 RVA: 0x00033C04 File Offset: 0x00031E04 private string QuotedString(string value) { if (this.version == 0 || this.IsToken(value)) { return value; } return "\"" + value.Replace("\"", "\\\"") + "\""; } // Token: 0x06001198 RID: 4504 RVA: 0x00033C4C File Offset: 0x00031E4C private bool IsToken(string value) { int length = value.Length; for (int i = 0; i < length; i++) { char c = value[i]; if (c < ' ' || c >= '\u007f' || Cookie.tspecials.IndexOf(c) != -1) { return false; } } return true; } // Token: 0x06001199 RID: 4505 RVA: 0x00033CA0 File Offset: 0x00031EA0 private static bool IsNullOrEmpty(string s) { return s == null || s.Length == 0; } // Token: 0x04000F78 RID: 3960 private string comment; // Token: 0x04000F79 RID: 3961 private global::System.Uri commentUri; // Token: 0x04000F7A RID: 3962 private bool discard; // Token: 0x04000F7B RID: 3963 private string domain; // Token: 0x04000F7C RID: 3964 private DateTime expires; // Token: 0x04000F7D RID: 3965 private bool httpOnly; // Token: 0x04000F7E RID: 3966 private string name; // Token: 0x04000F7F RID: 3967 private string path; // Token: 0x04000F80 RID: 3968 private string port; // Token: 0x04000F81 RID: 3969 private int[] ports; // Token: 0x04000F82 RID: 3970 private bool secure; // Token: 0x04000F83 RID: 3971 private DateTime timestamp; // Token: 0x04000F84 RID: 3972 private string val; // Token: 0x04000F85 RID: 3973 private int version; // Token: 0x04000F86 RID: 3974 private static char[] reservedCharsName = new char[] { ' ', '=', ';', ',', '\n', '\r', '\t' }; // Token: 0x04000F87 RID: 3975 private static char[] portSeparators = new char[] { '"', ',' }; // Token: 0x04000F88 RID: 3976 private static string tspecials = "()<>@,;:\\\"/[]?={} \t"; // Token: 0x04000F89 RID: 3977 private bool exact_domain; } }