Author: olegk Date: Thu May 4 03:29:08 2006 New Revision: 399651 URL: http://svn.apache.org/viewcvs?rev=399651&view=rev Log: Checked compliance with the spec
Modified: jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java Modified: jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java?rev=399651&r1=399650&r2=399651&view=diff ============================================================================== --- jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java (original) +++ jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java Thu May 4 03:29:08 2006 @@ -540,7 +540,7 @@ * @param host host name where cookie is received from or being sent to. * @return */ - private String getEffectiveHost(String host) { + private static String getEffectiveHost(final String host) { String effectiveHost = host; if (host.indexOf('.') < 0) { effectiveHost += ".local"; @@ -689,7 +689,6 @@ if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } - //TODO (jain): how do we handle the case when domain is specified and equals host? if (domain == null) { throw new MalformedCookieException( "Missing value for domain attribute"); @@ -699,9 +698,14 @@ "Blank value for domain attribute"); } domain = domain.toLowerCase(); - // put a leading dot if domain does not start with a dot - if (!domain.startsWith(".")) + 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); } @@ -1077,12 +1081,6 @@ if (!cookie2.isVersionAttributeSpecified()) { throw new MalformedCookieException( "Violates RFC 2965. Version attribute is required."); - } - //TODO (jain): other versions for set-cookie2 ? - if (cookie2.getVersion() != 1) { - throw new MalformedCookieException( - "Violates RFC 2965. Invalid value for Version attribute." + - "Must be \"1\"."); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]