commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r400307 - /jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Date Sat, 06 May 2006 12:39:54 GMT
Author: olegk
Date: Sat May  6 05:39:52 2006
New Revision: 400307

URL: http://svn.apache.org/viewcvs?rev=400307&view=rev
Log:
Process Set-Cookie2 response headers ONLY if the actual cookie spec stands a chance of understanding
them

Modified:
    jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java

Modified: jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java?rev=400307&r1=400306&r2=400307&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
(original)
+++ jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Sat May  6 05:39:52 2006
@@ -1475,18 +1475,22 @@
         LOG.trace("enter HttpMethodBase.processResponseHeaders(HttpState, "
             + "HttpConnection)");
 
-        // process cookie headers
+        CookieSpec parser = getCookieSpec(state);
 
         // process set-cookie headers
         Header[] headers = getResponseHeaderGroup().getHeaders("set-cookie");
-        processCookieHeaders(headers, state, conn);
+        processCookieHeaders(parser, headers, state, conn);
 
-        // process set-cookie2 headers. Older cookie specs will ignore this
-        // header. For newer specs (like RFC 2965), set-cookie2 header will
-        // replace set-cookie header (obtained in the same response) for the
-        // same cookie.
-        headers = getResponseHeaderGroup().getHeaders("set-cookie2");
-        processCookieHeaders(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);
+            }
+        }
     }
 
     /**
@@ -1499,11 +1503,14 @@
      * @param conn the {@link HttpConnection connection} used to execute
      *        this HTTP method
      */
-    protected void processCookieHeaders(Header[] headers, HttpState state, HttpConnection
conn) {
+    protected void processCookieHeaders(
+            final CookieSpec parser, 
+            final Header[] headers, 
+            final HttpState state, 
+            final HttpConnection conn) {
         LOG.trace("enter HttpMethodBase.processCookieHeaders(Header[], HttpState, "
                   + "HttpConnection)");
 
-        CookieSpec parser = getCookieSpec(state);
         String host = this.params.getVirtualHost();
         if (host == null) {
             host = conn.getHost();



---------------------------------------------------------------------
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