/// <summary>Set 'effective host name' as defined in RFC 2965.</summary> /// <remarks> /// Set 'effective host name' as defined in RFC 2965. /// <p> /// If a host name contains no dots, the effective host name is /// that name with the string .local appended to it. Otherwise /// the effective host name is the same as the host name. Note /// that all effective host names contain at least one dot. /// </remarks> /// <param name="origin">origin where cookie is received from or being sent to.</param> private static CookieOrigin AdjustEffectiveHost(CookieOrigin origin) { string host = origin.GetHost(); // Test if the host name appears to be a fully qualified DNS name, // IPv4 address or IPv6 address bool isLocalHost = true; for (int i = 0; i < host.Length; i++) { char ch = host[i]; if (ch == '.' || ch == ':') { isLocalHost = false; break; } } if (isLocalHost) { host += ".local"; return(new CookieOrigin(host, origin.GetPort(), origin.GetPath(), origin.IsSecure ())); } else { return(origin); } }
public override bool Match(Apache.Http.Cookie.Cookie cookie, CookieOrigin origin) { Args.NotNull(cookie, "Cookie"); Args.NotNull(origin, "Cookie origin"); return(!cookie.IsSecure() || origin.IsSecure()); }