Code example for CookieOrigin

Methods: getHost

0
        // Validate the cookies domain attribute.  NOTE:  Domains without  
        // any dots are allowed to support hosts on private LANs that don't  
        // have DNS names.  Since they have no dots, to domain-match the  
        // request-host and domain must be identical for the cookie to sent  
        // back to the origin-server. 
        String host = origin.getHost();
        String domain = cookie.getDomain();
        if (domain == null) {
            throw new MalformedCookieException("Cookie domain may not be null");
        } 
        if (host.contains(".")) {
            // Not required to have at least two dots.  RFC 2965. 
            // A Set-Cookie2 with Domain=ajax.com will be accepted. 
 
            // domain must match host 
            if (!host.endsWith(domain)) {
                if (domain.startsWith(".")) {
                    domain = domain.substring(1, domain.length());
                } 
                if (!host.equals(domain)) { 
                    throw new MalformedCookieException(