incubator-wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From el...@apache.org
Subject svn commit: r789280 - /incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
Date Mon, 29 Jun 2009 10:34:15 GMT
Author: elman
Date: Mon Jun 29 10:34:15 2009
New Revision: 789280

URL: http://svn.apache.org/viewvc?rev=789280&view=rev
Log:
See https://issues.apache.org/jira/browse/WINK-15

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java?rev=789280&r1=789279&r2=789280&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
Mon Jun 29 10:34:15 2009
@@ -46,7 +46,7 @@
 
         ModifiableCookie firstCookie = null;
         int cookieNum = 0;
-
+        boolean versionSet = false;
         for (String token : tokens) {
             String[] subTokens = token.trim().split("=", 2);
             String name = subTokens.length > 0 ? subTokens[0] : null;
@@ -63,23 +63,27 @@
                     break;
                 }
                 if (firstCookie == null) {
-                    throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
+                    firstCookie = new ModifiableCookie();
                 }
                 firstCookie.name = name;
                 firstCookie.value = value;
-            } else if (name.trim().startsWith("$Version")) {
+            } else if (name.startsWith(VERSION)) {
                 if (firstCookie == null) {
                     firstCookie = new ModifiableCookie();
                 } else {
-                    throw new IllegalArgumentException("Cookie cannot contain additional
$Version: " + cookie);
+                    if (versionSet) {
+                        throw new IllegalArgumentException(
+                            "Cookie cannot contain additional $Version: " + cookie);
+                    }
                 }
+                versionSet = true;
                 firstCookie.version = Integer.parseInt(value);
-            } else if (name.startsWith("$Path") && cookie != null) {
+            } else if (name.startsWith(PATH) && cookie != null) {
                 if (firstCookie == null) {
                     throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
                 }
                 firstCookie.path = value;
-            } else if (name.trim().startsWith("$Domain") && cookie != null) {
+            } else if (name.startsWith(DOMAIN) && cookie != null) {
                 if (firstCookie == null) {
                     throw new IllegalArgumentException("Cookie must start with $Version:
" + cookie);
                 }
@@ -154,7 +158,7 @@
 
         public String name;
         public String value;
-        public int    version = Cookie.DEFAULT_VERSION;
+        public int    version = 0;
         public String path;
         public String domain;
     }



Mime
View raw message