hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r572573 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src: main/java/org/apache/http/conn/params/ main/java/org/apache/http/cookie/ main/java/org/apache/http/impl/conn/ main/java/org/apache/http/impl/cookie/ test/java/org/apac...
Date Tue, 04 Sep 2007 08:20:30 GMT
Author: olegk
Date: Tue Sep  4 01:20:29 2007
New Revision: 572573

URL: http://svn.apache.org/viewvc?rev=572573&view=rev
Log:
* Added ClientCookie interface that extends the standard Cookie interface with additional
client specific functionality such ability to retrieve original cookie attributes exactly
as they were specified by the origin server
* Cookie specs refactored to make use of the ClientCookie interface / code cleanups

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
  (with props)
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnParams.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicCookie.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnParams.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnParams.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/params/HttpConnParams.java
Tue Sep  4 01:20:29 2007
@@ -30,9 +30,7 @@
 
 package org.apache.http.conn.params;
 
-import org.apache.http.HttpHost;
 import org.apache.http.params.HttpParams;
-
 
 /**
  * An adaptor for accessing HTTP connection parameters in {@link HttpParams}.

Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java?rev=572573&view=auto
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
Tue Sep  4 01:20:29 2007
@@ -0,0 +1,62 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.cookie;
+
+/**
+ * ClientCookie extends the standard {@link Cookie} interface with 
+ * additional client specific functionality such ability to retrieve 
+ * original cookie attributes exactly as they were specified by the 
+ * origin server. This is important for generating the <tt>Cookie</tt> 
+ * header because some cookie specifications require that the 
+ * <tt>Cookie</tt> header should include certain attributes only if 
+ * they were specified in the <tt>Set-Cookie</tt> header.
+ * 
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ * 
+ * @since 4.0
+ */
+public interface ClientCookie extends Cookie {
+
+    // RFC2109 attributes
+    public static final String VERSION_ATTR    = "version";
+    public static final String PATH_ATTR       = "path";
+    public static final String DOMAIN_ATTR     = "domain";
+    public static final String MAX_AGE_ATTR    = "max-age";
+    public static final String SECURE_ATTR     = "secure";
+    public static final String COMMENT_ATTR    = "comment";
+    public static final String EXPIRES_ATTR    = "expires";
+    
+    String getAttribute(String name);
+    
+    boolean containsAttribute(String name);
+    
+}
\ No newline at end of file

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/ClientCookie.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/cookie/SetCookie.java
Tue Sep  4 01:20:29 2007
@@ -43,6 +43,8 @@
  */
 public interface SetCookie extends Cookie {
 
+    void setValue(String value);
+    
     /**
      * If a user agent (web browser) presents this cookie to a user, the
      * cookie's purpose will be described using this comment.
@@ -108,54 +110,6 @@
      * @see #getVersion
      */
     void setVersion(int version);
-
-    /**
-     * Returns <tt>true</tt> if cookie's path was set via a path attribute
-     * in the <tt>Set-Cookie</tt> header.
-     *
-     * @return value <tt>true</tt> if the cookie's path was explicitly 
-     * set, <tt>false</tt> otherwise.
-     */
-    boolean isPathAttributeSpecified();
-
-    /**
-     * Indicates whether the cookie had a path specified in a 
-     * path attribute of the <tt>Set-Cookie</tt> header. This value
-     * is important for generating the <tt>Cookie</tt> header because 
-     * some cookie specifications require that the <tt>Cookie</tt> header 
-     * should only include a path attribute if the cookie's path 
-     * was specified in the <tt>Set-Cookie</tt> header.
-     *
-     * @param value <tt>true</tt> if the cookie's path was explicitly 
-     * set, <tt>false</tt> otherwise.
-     * 
-     * @see #isPathAttributeSpecified
-     */
-    public void setPathAttributeSpecified(boolean value);
-
-    /**
-     * Returns <tt>true</tt> if cookie's domain was set via a domain 
-     * attribute in the <tt>Set-Cookie</tt> header.
-     *
-     * @return value <tt>true</tt> if the cookie's domain was explicitly 
-     * set, <tt>false</tt> otherwise.
-     */
-    boolean isDomainAttributeSpecified();
-
-    /**
-     * Indicates whether the cookie had a domain specified in a 
-     * domain attribute of the <tt>Set-Cookie</tt> header. This value
-     * is important for generating the <tt>Cookie</tt> header because 
-     * some cookie specifications require that the <tt>Cookie</tt> header 
-     * should only include a domain attribute if the cookie's domain 
-     * was specified in the <tt>Set-Cookie</tt> header.
-     *
-     * @param value <tt>true</tt> if the cookie's domain was explicitly 
-     * set, <tt>false</tt> otherwise.
-     *
-     * @see #isDomainAttributeSpecified
-     */
-    void setDomainAttributeSpecified(boolean value);
 
 }
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/DefaultResponseParser.java
Tue Sep  4 01:20:29 2007
@@ -44,7 +44,6 @@
 import org.apache.http.io.SessionInputBuffer;
 import org.apache.http.message.LineParser;
 import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
 public class DefaultResponseParser extends AbstractMessageParser {

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicCookie.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicCookie.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicCookie.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicCookie.java
Tue Sep  4 01:20:29 2007
@@ -32,16 +32,17 @@
 package org.apache.http.impl.cookie;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.SetCookie;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
- * <p>
  * HTTP "magic-cookie" represents a piece of state information
  * that the HTTP agent and the target server can exchange to maintain 
  * a session.
- * </p>
  * 
  * @author B.C. Holmes
  * @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
@@ -56,7 +57,7 @@
  * 
  * @version $Revision$
  */
-public class BasicCookie implements SetCookie {
+public class BasicCookie implements SetCookie, ClientCookie {
 
     /**
      * Default Constructor taking a name and a value. The value may be null.
@@ -70,6 +71,7 @@
             throw new IllegalArgumentException("Name may not be null");
         }
         this.name = name;
+        this.attribs = new HashMap();
         this.value = value;
     }
 
@@ -92,6 +94,15 @@
     }
 
     /**
+     * Sets the value
+     * 
+     * @param value
+     */
+    public void setValue(final String value) {
+        this.value = value;
+    }
+
+    /**
      * Returns the comment describing the purpose of this cookie, or
      * <tt>null</tt> if no such comment has been defined.
      * 
@@ -271,64 +282,16 @@
             && cookieExpiryDate.getTime() <= date.getTime());
     }
 
-    /**
-     * Indicates whether the cookie had a path specified in a 
-     * path attribute of the <tt>Set-Cookie</tt> header. This value
-     * is important for generating the <tt>Cookie</tt> header because 
-     * some cookie specifications require that the <tt>Cookie</tt> header 
-     * should only include a path attribute if the cookie's path 
-     * was specified in the <tt>Set-Cookie</tt> header.
-     *
-     * @param value <tt>true</tt> if the cookie's path was explicitly 
-     * set, <tt>false</tt> otherwise.
-     * 
-     * @see #isPathAttributeSpecified
-     */
-    public void setPathAttributeSpecified(boolean value) {
-        hasPathAttribute = value;
+    public void setAttribute(final String name, final String value) {
+        this.attribs.put(name, value);
     }
-
-    /**
-     * Returns <tt>true</tt> if cookie's path was set via a path attribute
-     * in the <tt>Set-Cookie</tt> header.
-     *
-     * @return value <tt>true</tt> if the cookie's path was explicitly 
-     * set, <tt>false</tt> otherwise.
-     * 
-     * @see #setPathAttributeSpecified
-     */
-    public boolean isPathAttributeSpecified() {
-        return hasPathAttribute;
-    }
-
-    /**
-     * Indicates whether the cookie had a domain specified in a 
-     * domain attribute of the <tt>Set-Cookie</tt> header. This value
-     * is important for generating the <tt>Cookie</tt> header because 
-     * some cookie specifications require that the <tt>Cookie</tt> header 
-     * should only include a domain attribute if the cookie's domain 
-     * was specified in the <tt>Set-Cookie</tt> header.
-     *
-     * @param value <tt>true</tt> if the cookie's domain was explicitly 
-     * set, <tt>false</tt> otherwise.
-     *
-     * @see #isDomainAttributeSpecified
-     */
-    public void setDomainAttributeSpecified(boolean value) {
-        hasDomainAttribute = value;
+    
+    public String getAttribute(final String name) {
+        return (String) this.attribs.get(name);
     }
 
-    /**
-     * Returns <tt>true</tt> if cookie's domain was set via a domain 
-     * attribute in the <tt>Set-Cookie</tt> header.
-     *
-     * @return value <tt>true</tt> if the cookie's domain was explicitly 
-     * set, <tt>false</tt> otherwise.
-     *
-     * @see #setDomainAttributeSpecified
-     */
-    public boolean isDomainAttributeSpecified() {
-        return hasDomainAttribute;
+    public boolean containsAttribute(final String name) {
+        return this.attribs.get(name) != null;
     }
 
     public String toString() {
@@ -354,42 +317,34 @@
         return buffer.toString();
     }
     
-    
    // ----------------------------------------------------- Instance Variables
 
-
+    /** Cookie name */
     private final String name;
-    private final String value;
-
-   /** Comment attribute. */
-   private String  cookieComment;
 
-   /** Domain attribute. */
-   private String  cookieDomain;
+    /** Cookie attributes as specified by the origin server */
+    private final Map attribs;
+   
+    /** Cookie value */
+    private String value;
 
-   /** Expiration {@link Date}. */
-   private Date    cookieExpiryDate;
+    /** Comment attribute. */
+    private String  cookieComment;
 
-   /** Path attribute. */
-   private String  cookiePath;
+    /** Domain attribute. */
+    private String  cookieDomain;
 
-   /** My secure flag. */
-   private boolean isSecure;
+    /** Expiration {@link Date}. */
+    private Date cookieExpiryDate;
 
-   /**
-    * Specifies if the set-cookie header included a Path attribute for this
-    * cookie
-    */
-   private boolean hasPathAttribute = false;
+    /** Path attribute. */
+    private String cookiePath;
 
-   /**
-    * Specifies if the set-cookie header included a Domain attribute for this
-    * cookie
-    */
-   private boolean hasDomainAttribute = false;
+    /** My secure flag. */
+    private boolean isSecure;
 
-   /** The version of the cookie specification I was created from. */
-   private int     cookieVersion = 0;
+    /** The version of the cookie specification I was created from. */
+    private int cookieVersion = 0;
 
 }
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
Tue Sep  4 01:20:29 2007
@@ -54,7 +54,6 @@
             throw new MalformedCookieException("Blank value for domain attribute");
         }
         cookie.setDomain(value);
-        cookie.setDomainAttributeSpecified(true);
     }
 
     public void validate(final Cookie cookie, final CookieOrigin origin) 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
Tue Sep  4 01:20:29 2007
@@ -51,7 +51,6 @@
             value = "/";
         }
         cookie.setPath(value);
-        cookie.setPathAttributeSpecified(true);
     }
 
     public void validate(final Cookie cookie, final CookieOrigin origin) 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
Tue Sep  4 01:20:29 2007
@@ -33,6 +33,7 @@
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
@@ -41,9 +42,8 @@
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.util.CharArrayBuffer;
 
-
 /**
- * Cookie specification that stives to closely mimic (mis)behavior of 
+ * Cookie specification that strives to closely mimic (mis)behavior of 
  * common web browser applications such as Microsoft Internet Explorer
  * and Mozilla FireFox.
  *
@@ -81,12 +81,13 @@
         } else {
             this.datepatterns = DATE_PATTERNS;
         }
-        registerAttribHandler("path", new BasicPathHandler());
-        registerAttribHandler("domain", new BasicDomainHandler());
-        registerAttribHandler("max-age", new BasicMaxAgeHandler());
-        registerAttribHandler("secure", new BasicSecureHandler());
-        registerAttribHandler("comment", new BasicCommentHandler());
-        registerAttribHandler("expires", new BasicExpiresHandler(this.datepatterns));
+        registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
+        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new BasicDomainHandler());
+        registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
+        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
+        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
+        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
+                this.datepatterns));
     }
 
     /** Default constructor */

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
Tue Sep  4 01:20:29 2007
@@ -39,7 +39,6 @@
 import org.apache.http.cookie.CookieAttributeHandler;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SetCookie;
 
 /**
  * Cookie management functions shared by all specification.
@@ -79,7 +78,7 @@
                 throw new MalformedCookieException("Cookie name may not be empty");
             }
             
-            SetCookie cookie = new BasicCookie(name, value);
+            BasicCookie cookie = new BasicCookie(name, value);
             cookie.setPath(getDefaultPath(origin));
             cookie.setDomain(getDefaultDomain(origin));
             
@@ -88,6 +87,9 @@
             for (int j = attribs.length - 1; j >= 0; j--) {
                 NameValuePair attrib = attribs[j];
                 String s = attrib.getName().toLowerCase();
+                
+                cookie.setAttribute(s, attrib.getValue());
+                
                 CookieAttributeHandler handler = findAttribHandler(s);
                 if (handler != null) {
                     handler.parse(cookie, attrib.getValue());

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDraftSpec.java
Tue Sep  4 01:20:29 2007
@@ -33,6 +33,7 @@
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
@@ -62,12 +63,12 @@
     /** Default constructor */
     public NetscapeDraftSpec() {
         super();
-        registerAttribHandler("path", new BasicPathHandler());
-        registerAttribHandler("domain", new NetscapeDomainHandler());
-        registerAttribHandler("max-age", new BasicMaxAgeHandler());
-        registerAttribHandler("secure", new BasicSecureHandler());
-        registerAttribHandler("comment", new BasicCommentHandler());
-        registerAttribHandler("expires", new BasicExpiresHandler(
+        registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
+        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new NetscapeDomainHandler());
+        registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
+        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
+        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
+        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
                 new String[] {"EEE, dd-MMM-yyyy HH:mm:ss z"}));
     }
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
Tue Sep  4 01:20:29 2007
@@ -54,7 +54,6 @@
             throw new MalformedCookieException("Blank value for domain attribute");
         }
         cookie.setDomain(value);
-        cookie.setDomainAttributeSpecified(true);
     }
 
     public void validate(final Cookie cookie, final CookieOrigin origin) 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
Tue Sep  4 01:20:29 2007
@@ -35,16 +35,15 @@
 
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookiePathComparator;
 import org.apache.http.cookie.MalformedCookieException;
 import org.apache.http.cookie.SM;
-import org.apache.http.cookie.SetCookie;
 import org.apache.http.message.BufferedHeader;
 import org.apache.http.util.CharArrayBuffer;
 
-
 /**
  * RFC 2109 compliant cookie policy
  *
@@ -84,13 +83,14 @@
             this.datepatterns = DATE_PATTERNS;
         }
         this.oneHeader = oneHeader;
-        registerAttribHandler("version", new RFC2109VersionHandler());
-        registerAttribHandler("path", new BasicPathHandler());
-        registerAttribHandler("domain", new RFC2109DomainHandler());
-        registerAttribHandler("max-age", new BasicMaxAgeHandler());
-        registerAttribHandler("secure", new BasicSecureHandler());
-        registerAttribHandler("comment", new BasicCommentHandler());
-        registerAttribHandler("expires", new BasicExpiresHandler(this.datepatterns));
+        registerAttribHandler(ClientCookie.VERSION_ATTR, new RFC2109VersionHandler());
+        registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
+        registerAttribHandler(ClientCookie.DOMAIN_ATTR, new RFC2109DomainHandler());
+        registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
+        registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
+        registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
+        registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
+                this.datepatterns));
     }
 
     /** Default constructor */
@@ -142,7 +142,7 @@
 
     private Header[] doFormatOneHeader(final Cookie[] cookies) {
         int version = Integer.MAX_VALUE;
-        // Pick the lowerest common denominator
+        // Pick the lowest common denominator
         for (int i = 0; i < cookies.length; i++) {
             Cookie cookie = cookies[i];
             if (cookie.getVersion() < version) {
@@ -152,7 +152,8 @@
         CharArrayBuffer buffer = new CharArrayBuffer(40 * cookies.length);
         buffer.append(SM.COOKIE);
         buffer.append(": ");
-        formatParamAsVer(buffer, "$Version", Integer.toString(version), version);
+        buffer.append("$Version=");
+        buffer.append(Integer.toString(version));
         for (int i = 0; i < cookies.length; i++) {
             buffer.append("; ");
             Cookie cookie = cookies[i];
@@ -168,7 +169,8 @@
             int version = cookie.getVersion();
             CharArrayBuffer buffer = new CharArrayBuffer(40);
             buffer.append("Cookie: ");
-            formatParamAsVer(buffer, "$Version", Integer.toString(version), version);
+            buffer.append("$Version=");
+            buffer.append(Integer.toString(version));
             buffer.append("; ");
             formatCookieAsVer(buffer, cookies[i], version);
             headers[i] = new BufferedHeader(buffer);
@@ -210,13 +212,15 @@
             final Cookie cookie, int version) {
         formatParamAsVer(buffer, cookie.getName(), cookie.getValue(), version);
         if (cookie.getPath() != null) {
-            if (cookie instanceof SetCookie && ((SetCookie) cookie).isPathAttributeSpecified())
{
+            if (cookie instanceof ClientCookie 
+                    && ((ClientCookie) cookie).containsAttribute(ClientCookie.PATH_ATTR))
{
                 buffer.append("; ");
                 formatParamAsVer(buffer, "$Path", cookie.getPath(), version);
             }
         }
         if (cookie.getDomain() != null) {
-            if (cookie instanceof SetCookie && ((SetCookie) cookie).isDomainAttributeSpecified())
{
+            if (cookie instanceof ClientCookie 
+                    && ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR))
{
                 buffer.append("; ");
                 formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version);
             }

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBasicCookieAttribHandlers.java
Tue Sep  4 01:20:29 2007
@@ -43,7 +43,6 @@
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.MalformedCookieException;
 
-
 public class TestBasicCookieAttribHandlers extends TestCase {
 
     public TestBasicCookieAttribHandlers(String testName) {
@@ -65,7 +64,6 @@
         CookieAttributeHandler h = new BasicDomainHandler();
         h.parse(cookie, "www.somedomain.com");
         assertEquals("www.somedomain.com", cookie.getDomain());
-        assertTrue(cookie.isDomainAttributeSpecified());
     }
 
     public void testBasicDomainParseInvalid() throws Exception {
@@ -215,13 +213,10 @@
         CookieAttributeHandler h = new BasicPathHandler();
         h.parse(cookie, "stuff");
         assertEquals("stuff", cookie.getPath());
-        assertTrue(cookie.isPathAttributeSpecified());
         h.parse(cookie, "");
         assertEquals("/", cookie.getPath());
-        assertTrue(cookie.isPathAttributeSpecified());
         h.parse(cookie, null);
         assertEquals("/", cookie.getPath());
-        assertTrue(cookie.isPathAttributeSpecified());
     }
 
     public void testBasicPathMatch1() throws Exception {

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestBrowserCompatSpec.java
Tue Sep  4 01:20:29 2007
@@ -37,6 +37,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.Header;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
@@ -660,9 +661,9 @@
     public void testSecondDomainLevelCookie() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
@@ -672,9 +673,9 @@
     public void testSecondDomainLevelCookieMatch1() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
@@ -684,9 +685,9 @@
     public void testSecondDomainLevelCookieMatch2() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain("sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("www.sourceforge.net", 80, "/", false);
@@ -696,9 +697,9 @@
     public void testSecondDomainLevelCookieMatch3() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
          CookieSpec cookiespec = new BrowserCompatSpec();
          CookieOrigin origin = new CookieOrigin("www.sourceforge.net", 80, "/", false);
@@ -708,9 +709,9 @@
     public void testInvalidSecondDomainLevelCookieMatch1() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("antisourceforge.net", 80, "/", false);
@@ -720,9 +721,9 @@
     public void testInvalidSecondDomainLevelCookieMatch2() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain("sourceforge.net");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("antisourceforge.net", 80, "/", false);
@@ -848,9 +849,9 @@
     public void testInvalidMatchDomain() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null); 
         cookie.setDomain("beta.gamma.com");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         CookieOrigin origin = new CookieOrigin("alpha.beta.gamma.com", 80, "/", false); 
@@ -880,9 +881,9 @@
     public void testNullCookieValueFormatting() {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".whatever.com");
-        cookie.setDomainAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new BrowserCompatSpec();
         Header[] headers = cookiespec.formatCookies(new Cookie[]{ cookie });

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieNetscapeDraft.java
Tue Sep  4 01:20:29 2007
@@ -35,6 +35,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.Header;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
@@ -211,9 +212,9 @@
     public void testFormatCookies() throws Exception {
         BasicCookie c1 = new BasicCookie("name1", "value1");
         c1.setDomain(".whatever.com");
-        c1.setDomainAttributeSpecified(true);
+        c1.setAttribute(ClientCookie.DOMAIN_ATTR, c1.getDomain());
         c1.setPath("/");
-        c1.setPathAttributeSpecified(true);
+        c1.setAttribute(ClientCookie.PATH_ATTR, c1.getPath());
 
         Cookie c2 = new BasicCookie("name2", "value2");
         Cookie c3 = new BasicCookie("name3", null);

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java?rev=572573&r1=572572&r2=572573&view=diff
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/impl/cookie/TestCookieRFC2109Spec.java
Tue Sep  4 01:20:29 2007
@@ -35,6 +35,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.Header;
+import org.apache.http.cookie.ClientCookie;
 import org.apache.http.cookie.Cookie;
 import org.apache.http.cookie.CookieOrigin;
 import org.apache.http.cookie.CookieSpec;
@@ -171,9 +172,9 @@
     public void testSecondDomainLevelCookie() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setDomainAttributeSpecified(true);
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new RFC2109Spec();
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
@@ -188,9 +189,9 @@
     public void testSecondDomainLevelCookieMatch() throws Exception {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".sourceforge.net");
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setDomainAttributeSpecified(true);
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new RFC2109Spec();
         CookieOrigin origin = new CookieOrigin("sourceforge.net", 80, "/", false);
@@ -300,14 +301,14 @@
     public void testRFC2109CookieFormatting() throws Exception {
         CookieSpec cookiespec = new RFC2109Spec(null, false);
         Header header = new BasicHeader("Set-Cookie", 
-            "name=\"value\"; version=\"1\"; path=\"/\"; domain=\".mydomain.com\"");
+            "name=\"value\"; version=1; path=\"/\"; domain=\".mydomain.com\"");
         CookieOrigin origin = new CookieOrigin("myhost.mydomain.com", 80, "/", false);
         Cookie[] cookies  = cookiespec.parse(header, origin);
         cookiespec.validate(cookies[0], origin);
         Header[] headers = cookiespec.formatCookies(cookies);
         assertNotNull(headers);
         assertEquals(1, headers.length);
-        assertEquals("$Version=\"1\"; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",

+        assertEquals("$Version=1; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"",

                 headers[0].getValue());
 
         header = new BasicHeader( "Set-Cookie", 
@@ -352,7 +353,7 @@
         assertEquals(2, cookies.length);
         headers = cookiespec.formatCookies(cookies);
         assertEquals( 
-            "$Version=\"1\"; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; "
+ 
+            "$Version=1; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; " + 
             "name2=\"value2\"; $Path=\"/\"; $Domain=\".mydomain.com\"",
             headers[0].getValue());
     }
@@ -363,9 +364,9 @@
     public void testNullCookieValueFormatting() {
         BasicCookie cookie = new BasicCookie("name", null);
         cookie.setDomain(".whatever.com");
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, cookie.getDomain());
         cookie.setPath("/");
-        cookie.setDomainAttributeSpecified(true);
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new RFC2109Spec();
         Header[] headers = cookiespec.formatCookies(new Cookie[] { cookie });
@@ -378,15 +379,14 @@
         headers = cookiespec.formatCookies(new Cookie[] { cookie });
         assertNotNull(headers);
         assertEquals(1, headers.length);
-        assertEquals("$Version=\"1\"; name=; $Path=\"/\"; $Domain=\".whatever.com\"", 
+        assertEquals("$Version=1; name=; $Path=\"/\"; $Domain=\".whatever.com\"", 
                 headers[0].getValue());
     }
 
     public void testCookieNullDomainNullPathFormatting() {
         BasicCookie cookie = new BasicCookie("name", null); 
-        cookie.setDomainAttributeSpecified(true);
         cookie.setPath("/");
-        cookie.setPathAttributeSpecified(true);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, cookie.getPath());
 
         CookieSpec cookiespec = new RFC2109Spec();
         Header[] headers = cookiespec.formatCookies(new Cookie[] { cookie });
@@ -394,8 +394,8 @@
         assertEquals(1, headers.length);
         assertEquals("$Version=0; name=; $Path=/", headers[0].getValue());
 
-        cookie.setDomainAttributeSpecified(false);
-        cookie.setPathAttributeSpecified(false);
+        cookie.setAttribute(ClientCookie.DOMAIN_ATTR, null);
+        cookie.setAttribute(ClientCookie.PATH_ATTR, null);
         headers = cookiespec.formatCookies(new Cookie[] { cookie });
         assertNotNull(headers);
         assertEquals(1, headers.length);
@@ -405,16 +405,16 @@
     public void testCookieOrderingByPath() {
         BasicCookie c1 = new BasicCookie("name1", "value1");
         c1.setPath("/a/b/c");
-        c1.setPathAttributeSpecified(true);
+        c1.setAttribute(ClientCookie.PATH_ATTR, c1.getPath());
         BasicCookie c2 = new BasicCookie("name2", "value2");
         c2.setPath("/a/b");
-        c2.setPathAttributeSpecified(true);
+        c2.setAttribute(ClientCookie.PATH_ATTR, c2.getPath());
         BasicCookie c3 = new BasicCookie("name3", "value3");
         c3.setPath("/a");
-        c3.setPathAttributeSpecified(true);
+        c3.setAttribute(ClientCookie.PATH_ATTR, c3.getPath());
         BasicCookie c4 = new BasicCookie("name4", "value4");
         c4.setPath("/");
-        c4.setPathAttributeSpecified(true);
+        c4.setAttribute(ClientCookie.PATH_ATTR, c4.getPath());
 
         CookieSpec cookiespec = new RFC2109Spec(null, true);
         Header[] headers = cookiespec.formatCookies(new Cookie[] { c2, c4, c1, c3 });



Mime
View raw message