HttpCookie.DomainMatches(String, String) Method

Definition

The utility method to check whether a host name is in a domain or not.

[Android.Runtime.Register("domainMatches", "(Ljava/lang/String;Ljava/lang/String;)Z", "")]
public static bool DomainMatches (string? domain, string? host);
[<Android.Runtime.Register("domainMatches", "(Ljava/lang/String;Ljava/lang/String;)Z", "")>]
static member DomainMatches : string * string -> bool

Parameters

domain
String

the domain name to check host name with

host
String

the host name in question

Returns

true if they domain-matches; false if not

Attributes

Remarks

The utility method to check whether a host name is in a domain or not.

This concept is described in the cookie specification. To understand the concept, some terminologies need to be defined first: <blockquote> effective host name = hostname if host name contains dot<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or = hostname.local if not </blockquote>

Host A's name domain-matches host B's if: <blockquote><ul> <li>their host name strings string-compare equal; or</li> <li>A is a HDN string and has the form NB, where N is a non-empty name string, B has the form .B', and B' is a HDN string. (So, x.y.com domain-matches .Y.com but not Y.com.)</li> </ul></blockquote>

A host isn't in a domain (RFC 2965 sec. 3.3.2) if: <blockquote><ul> <li>The value for the Domain attribute contains no embedded dots, and the value is not .local.</li> <li>The effective host name that derives from the request-host does not domain-match the Domain attribute.</li> <li>The request-host is a HDN (not IP address) and has the form HD, where D is the value of the Domain attribute, and H is a string that contains one or more dots.</li> </ul></blockquote>

Examples: <blockquote><ul> <li>A Set-Cookie2 from request-host y.x.foo.com for Domain=.foo.com would be rejected, because H is y.x and contains a dot.</li> <li>A Set-Cookie2 from request-host x.foo.com for Domain=.foo.com would be accepted.</li> <li>A Set-Cookie2 with Domain=.com or Domain=.com., will always be rejected, because there is no embedded dot.</li> <li>A Set-Cookie2 from request-host example for Domain=.local will be accepted, because the effective host name for the request- host is example.local, and example.local domain-matches .local.</li> </ul></blockquote>

Java documentation for java.net.HttpCookie.domainMatches(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to