commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oglu...@apache.org
Subject svn commit: r290666 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/cookie/RFC2109Spec.java test/org/apache/commons/httpclient/cookie/TestCookieRFC2109Spec.java
Date Wed, 21 Sep 2005 09:31:06 GMT
Author: oglueck
Date: Wed Sep 21 02:30:56 2005
New Revision: 290666

URL: http://svn.apache.org/viewcvs?rev=290666&view=rev
Log:
Fixed pair ordering
PR #36740 (Minor RFC 2109 / 2965 violation)
Contributed by Ortwin Gl├╝ck
Reviewed by Oleg Kalnichevski

Modified:
    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/TestCookieRFC2109Spec.java

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=290666&r1=290665&r2=290666&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
Wed Sep 21 02:30:56 2005
@@ -222,14 +222,14 @@
             value = "";
         }
         formatParam(buffer, new NameValuePair(cookie.getName(), value), version);
-        if (cookie.getDomain() != null 
+        if ((cookie.getPath() != null) && cookie.isPathAttributeSpecified()) {
+          buffer.append("; ");
+          formatParam(buffer, new NameValuePair("$Path", cookie.getPath()), version);
+        }
+        if ((cookie.getDomain() != null) 
             && cookie.isDomainAttributeSpecified()) {
             buffer.append("; ");
             formatParam(buffer, new NameValuePair("$Domain", cookie.getDomain()), version);
-        }
-        if (cookie.getPath() != null && cookie.isPathAttributeSpecified()) {
-            buffer.append("; ");
-            formatParam(buffer, new NameValuePair("$Path", cookie.getPath()), version);
         }
     }
 

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2109Spec.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2109Spec.java?rev=290666&r1=290665&r2=290666&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2109Spec.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/cookie/TestCookieRFC2109Spec.java
Wed Sep 21 02:30:56 2005
@@ -333,14 +333,14 @@
         Cookie[] cookies  = cookiespec.parse("myhost.mydomain.com", 80, "/", false, header
);
         cookiespec.validate("myhost.mydomain.com", 80, "/", false, cookies[0]);
         String s1 = cookiespec.formatCookie(cookies[0]);
-        assertEquals(s1, "$Version=\"1\"; name=\"value\"; $Domain=\".mydomain.com\"; $Path=\"/\"");
+        assertEquals(s1, "$Version=\"1\"; name=\"value\"; $Path=\"/\"; $Domain=\".mydomain.com\"");
 
         header = new Header( "Set-Cookie", 
             "name=value; path=/; domain=.mydomain.com");
         cookies = cookiespec.parse("myhost.mydomain.com", 80, "/", false, header );
         cookiespec.validate("myhost.mydomain.com", 80, "/", false, cookies[0]);
         String s2 = cookiespec.formatCookie(cookies[0]);
-        assertEquals(s2, "$Version=0; name=value; $Domain=.mydomain.com; $Path=/");
+        assertEquals(s2, "$Version=0; name=value; $Path=/; $Domain=.mydomain.com");
     }
 
     public void testRFC2109CookiesFormatting() throws Exception {
@@ -353,8 +353,8 @@
         assertEquals(2, cookies.length);
         String s1 = cookiespec.formatCookies(cookies);
         assertEquals(s1, 
-            "$Version=0; name1=value1; $Domain=.mydomain.com; $Path=/; " + 
-            "name2=value2; $Domain=.mydomain.com; $Path=/");
+            "$Version=0; name1=value1; $Path=/; $Domain=.mydomain.com; " + 
+            "name2=value2; $Path=/; $Domain=.mydomain.com");
 
         header = new Header("Set-Cookie", 
             "name1=value1; version=1; path=/; domain=.mydomain.com, " + 
@@ -364,8 +364,8 @@
         assertEquals(2, cookies.length);
         String s2 = cookiespec.formatCookies(cookies);
         assertEquals(s2, 
-            "$Version=\"1\"; name1=\"value1\"; $Domain=\".mydomain.com\"; $Path=\"/\"; "
+ 
-            "name2=\"value2\"; $Domain=\".mydomain.com\"; $Path=\"/\"");
+            "$Version=\"1\"; name1=\"value1\"; $Path=\"/\"; $Domain=\".mydomain.com\"; "
+ 
+            "name2=\"value2\"; $Path=\"/\"; $Domain=\".mydomain.com\"");
     }
     
     /**
@@ -378,11 +378,11 @@
 
         CookieSpec cookiespec = new RFC2109Spec();
         String s = cookiespec.formatCookie(cookie);
-        assertEquals("$Version=0; name=; $Domain=.whatever.com; $Path=/", s);
+        assertEquals("$Version=0; name=; $Path=/; $Domain=.whatever.com", s);
 
         cookie.setVersion(1);
         s = cookiespec.formatCookie(cookie);
-        assertEquals("$Version=\"1\"; name=\"\"; $Domain=\".whatever.com\"; $Path=\"/\"",
s);
+        assertEquals("$Version=\"1\"; name=\"\"; $Path=\"/\"; $Domain=\".whatever.com\"",
s);
     }
 
     public void testCookieNullDomainNullPathFormatting() {



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