commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r397879 - /jakarta/commons/proper/httpclient/branches/COOKIE_2_BRANCH/src/java/org/apache/commons/httpclient/cookie/RFC2965Spec.java
Date Fri, 28 Apr 2006 12:22:19 GMT
Author: olegk
Date: Fri Apr 28 05:22:17 2006
New Revision: 397879

URL: http://svn.apache.org/viewcvs?rev=397879&view=rev
Log:
Use RFC 2109 cookie spec as a fallback cookie policy when dealing with older cookies. 

It is not a very good idea to look up the fallback spec by id using CookiePolicy.getCookieSpec,
as (at least in theory) one can register any arbitrary cookie policy for that id, whereas
we definitely want specific behaviour from a specific cookie 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=397879&r1=397878&r2=397879&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
Fri Apr 28 05:22:17 2006
@@ -67,6 +67,11 @@
     */
     private final Map attribHandlerMap;
 
+    /**
+     * Fallback cookie spec (RFC 2109)
+     */
+    private final CookieSpec rfc2109;
+    
     /** 
      * Default constructor 
      * */
@@ -76,6 +81,7 @@
         this.formatter.setAlwaysUseQuotes(true);
         this.attribHandlerMap = new HashMap(10);        
         this.attribHandlerList = new ArrayList(10);
+        this.rfc2109 = new RFC2109Spec();
         
         registerAttribHandler(Cookie2.COOKIE_NAME_KEY, new Cookie2NameAttributeHandler());
         registerAttribHandler(Cookie2.PATH, new Cookie2PathAttributeHandler());
@@ -187,8 +193,7 @@
             return parse(host, port, path, secure, header.getValue());
         } else if (header.getName().equalsIgnoreCase(RFC2109Spec.SET_COOKIE_KEY)) {
             // delegate parsing of old-style cookies to rfc2109Spec
-            CookieSpec rfc2109Spec = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109);
-            return rfc2109Spec.parse(host, port, path, secure, header.getValue());
+            return this.rfc2109.parse(host, port, path, secure, header.getValue());
         } else {
             throw new MalformedCookieException("Header name is not valid. " +
                                                "RFC 2965 supports \"set-cookie\" " +
@@ -341,8 +346,7 @@
 
         if (!(cookie instanceof Cookie2)) {
             // old-style cookies are validated according to the old rules
-            CookieSpec rfc2109Spec = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109);
-            rfc2109Spec.validate(host, port, path, secure, cookie);
+            this.rfc2109.validate(host, port, path, secure, cookie);
             return;
         }
         CookieSource cookiesource = new CookieSource(host, port, path, secure); 
@@ -374,8 +378,7 @@
 
         if (!(cookie instanceof Cookie2)) {
             // old-style cookies are matched according to the old rules
-            CookieSpec rfc2109Spec = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109);
-            return rfc2109Spec.match(host, port, path, secure, cookie);
+            return this.rfc2109.match(host, port, path, secure, cookie);
         }
         CookieSource cookiesource = new CookieSource(host, port, path, secure); 
         for (Iterator i = getAttribHandlerIterator(); i.hasNext(); ) {
@@ -411,8 +414,7 @@
         }
         if (!(cookieParam instanceof Cookie2)) {
             // old-style cookies are formatted according to the old rules
-            CookieSpec rfc2109Spec = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109);
-            return rfc2109Spec.formatCookie(cookieParam);
+            return this.rfc2109.formatCookie(cookieParam);
         }
 
         /* format cookie2 cookie */
@@ -450,8 +452,7 @@
         // TODO(jain): check this logic?
         if (hasOldStyleCookie) {
             // delegate old-style cookie formatting to rfc2109Spec
-            CookieSpec rfc2109Spec = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109);
-            return rfc2109Spec.formatCookies(cookies);
+            return this.rfc2109.formatCookies(cookies);
         }
 
         /* format cookie2 cookies */



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