commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r400312 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/ java/org/apache/commons/httpclient/cookie/ test/org/apache/commons/httpclient/cookie/
Date Sat, 06 May 2006 12:49:43 GMT
Author: olegk
Date: Sat May  6 05:49:41 2006
New Revision: 400312

URL: http://svn.apache.org/viewcvs?rev=400312&view=rev
Log:
Merged down the diff from the COOKIE_2_BRANCH

Added:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/Cookie2.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/Cookie2.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieAttributeHandler.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/CookieAttributeHandler.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieOrigin.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/CookieOrigin.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePathComparator.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/CookiePathComparator.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieVersionSupport.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/CookieVersionSupport.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookie2.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/test/org/apache/commons/httpclient/cookie/TestCookie2.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookiePathComparator.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/test/org/apache/commons/httpclient/cookie/TestCookiePathComparator.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2965Spec.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2965Spec.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java
      - copied unchanged from r399747, jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/test/org/apache/commons/httpclient/cookie/TestCookieVersionSupport.java
Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java?rev=400312&r1=400311&r2=400312&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Sat May  6 05:49:41 2006
@@ -39,6 +39,7 @@
 import org.apache.commons.httpclient.auth.AuthState;
 import org.apache.commons.httpclient.cookie.CookiePolicy;
 import org.apache.commons.httpclient.cookie.CookieSpec;
+import org.apache.commons.httpclient.cookie.CookieVersionSupport;
 import org.apache.commons.httpclient.cookie.MalformedCookieException;
 import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.commons.httpclient.protocol.Protocol;
@@ -1190,6 +1191,20 @@
                     getRequestHeaderGroup().addHeader(new Header("Cookie", s, true));
                 }
             }
+            if (matcher instanceof CookieVersionSupport) {
+                CookieVersionSupport versupport = (CookieVersionSupport) matcher;
+                int ver = versupport.getVersion();
+                boolean needVersionHeader = false;
+                for (int i = 0; i < cookies.length; i++) {
+                    if (ver != cookies[i].getVersion()) {
+                        needVersionHeader = true;
+                    }
+                }
+                if (needVersionHeader) {
+                    // Advertise cookie version support
+                    getRequestHeaderGroup().addHeader(versupport.getVersionHeader());
+                }
+            }
         }
     }
 
@@ -1462,14 +1477,42 @@
         LOG.trace("enter HttpMethodBase.processResponseHeaders(HttpState, "
             + "HttpConnection)");
 
-        Header[] headers = getResponseHeaderGroup().getHeaders("set-cookie2");
-        //Only process old style set-cookie headers if new style headres
-        //are not present
-        if (headers.length == 0) { 
-            headers = getResponseHeaderGroup().getHeaders("set-cookie");
-        }
-        
         CookieSpec parser = getCookieSpec(state);
+
+        // process set-cookie headers
+        Header[] headers = getResponseHeaderGroup().getHeaders("set-cookie");
+        processCookieHeaders(parser, headers, state, conn);
+
+        // see if the cookie spec supports cookie versioning.
+        if (parser instanceof CookieVersionSupport) {
+            CookieVersionSupport versupport = (CookieVersionSupport) parser;
+            if (versupport.getVersion() > 0) {
+                // process set-cookie2 headers.
+                // Cookie2 will replace equivalent Cookie instances
+                headers = getResponseHeaderGroup().getHeaders("set-cookie2");
+                processCookieHeaders(parser, headers, state, conn);
+            }
+        }
+    }
+
+    /**
+     * This method processes the specified cookie headers. It is invoked from
+     * within {@link #processResponseHeaders(HttpState,HttpConnection)}
+     *
+     * @param headers cookie {@link Header}s to be processed
+     * @param state the {@link HttpState state} information associated with
+     *        this HTTP method
+     * @param conn the {@link HttpConnection connection} used to execute
+     *        this HTTP method
+     */
+    protected void processCookieHeaders(
+            final CookieSpec parser, 
+            final Header[] headers, 
+            final HttpState state, 
+            final HttpConnection conn) {
+        LOG.trace("enter HttpMethodBase.processCookieHeaders(Header[], HttpState, "
+                  + "HttpConnection)");
+
         String host = this.params.getVirtualHost();
         if (host == null) {
             host = conn.getHost();

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java?rev=400312&r1=400311&r2=400312&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
Sat May  6 05:49:41 2006
@@ -80,8 +80,15 @@
      * @since 3.0
      */
     public static final String RFC_2109 = "rfc2109";
-    
-    /** 
+
+    /**
+     * The RFC 2965 compliant policy.
+     *
+     * @since 3.0
+     */
+    public static final String RFC_2965 = "rfc2965";
+
+    /**
      * The policy that ignores cookies. 
      * 
      * @since 3.0
@@ -98,6 +105,7 @@
     static {
         CookiePolicy.registerCookieSpec(DEFAULT, RFC2109Spec.class);
         CookiePolicy.registerCookieSpec(RFC_2109, RFC2109Spec.class);
+        CookiePolicy.registerCookieSpec(RFC_2965, RFC2965Spec.class);
         CookiePolicy.registerCookieSpec(BROWSER_COMPATIBILITY, CookieSpecBase.class);
         CookiePolicy.registerCookieSpec(NETSCAPE, NetscapeDraftSpec.class);
         CookiePolicy.registerCookieSpec(IGNORE_COOKIES, IgnoreCookiesSpec.class);
@@ -125,7 +133,14 @@
      */
     public static final int RFC2109 = 2;
 
-    /** 
+    /**
+     * The <tt>RFC2965</tt> RFC 2965 compliant policy.
+     *
+     * @deprecated Use {@link #RFC_2965}
+     */
+    public static final int RFC2965 = 3;
+
+    /**
      * The default cookie policy.
      *  
      * @deprecated Use {@link #DEFAULT} 
@@ -241,6 +256,8 @@
                 return new NetscapeDraftSpec(); 
             case RFC2109:
                 return new RFC2109Spec();
+            case RFC2965:
+                return new RFC2965Spec();
             default:
                 return getDefaultSpec(); 
         }
@@ -302,4 +319,5 @@
     public static CookieSpec getCompatibilitySpec() {
         return getSpecByPolicy(COMPATIBILITY);
     }
+    
 }

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java?rev=400312&r1=400311&r2=400312&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java
Sat May  6 05:49:41 2006
@@ -53,8 +53,14 @@
 public class RFC2109Spec extends CookieSpecBase {
 
     private final ParameterFormatter formatter;
-    
-    /** Default constructor */    
+
+    /**
+     * Cookie Response Header  name for cookies processed
+     * by this spec.
+     */
+    public static String SET_COOKIE_KEY = "set-cookie";
+
+    /** Default constructor */
     public RFC2109Spec() {
         super();
         this.formatter = new ParameterFormatter();

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java?rev=400312&r1=400311&r2=400312&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java
Sat May  6 05:49:41 2006
@@ -43,12 +43,16 @@
     public static Test suite() {
         TestSuite suite = new TestSuite();
         suite.addTest(TestCookie.suite());
+        suite.addTest(TestCookie2.suite());
         suite.addTest(TestCookieCompatibilitySpec.suite());
         suite.addTest(TestCookieRFC2109Spec.suite());
+        suite.addTest(TestCookieRFC2965Spec.suite());
         suite.addTest(TestCookieNetscapeDraft.suite());
         suite.addTest(TestCookieIgnoreSpec.suite());
         suite.addTest(TestCookiePolicy.suite());
         suite.addTest(TestDateParser.suite());
+        suite.addTest(TestCookiePathComparator.suite());
+        suite.addTest(TestCookieVersionSupport.suite());
         return suite;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message