Пример #1
0
 /** Parse cookie domain attribute. */
 public void parse(final Cookie cookie, String domain) throws MalformedCookieException {
   if (cookie == null) {
     throw new IllegalArgumentException("Cookie may not be null");
   }
   if (domain == null) {
     throw new MalformedCookieException("Missing value for domain attribute");
   }
   if (domain.trim().equals("")) {
     throw new MalformedCookieException("Blank value for domain attribute");
   }
   domain = domain.toLowerCase();
   if (!domain.startsWith(".")) {
     // Per RFC 2965 section 3.2.2
     // "... If an explicitly specified value does not start with
     // a dot, the user agent supplies a leading dot ..."
     // That effectively implies that the domain attribute
     // MAY NOT be an IP address of a host name
     domain = "." + domain;
   }
   cookie.setDomain(domain);
   cookie.setDomainAttributeSpecified(true);
 }