From 0da3fcbe51a07c9aba516f0e69fe733cfaabdff6 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 13 Mar 2009 12:59:29 +0000 Subject: [PATCH] Fixed a bug where CookieEncoder generates a cookie with 'version=2' --- .../org/jboss/netty/handler/codec/http/CookieEncoder.java | 2 +- .../jboss/netty/handler/codec/http/CookieEncoderTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/CookieEncoder.java b/src/main/java/org/jboss/netty/handler/codec/http/CookieEncoder.java index 45fefb02d8..391e12d3d2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/CookieEncoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/CookieEncoder.java @@ -101,7 +101,7 @@ public class CookieEncoder { add(sb, CookieHeaderNames.COMMENT, QueryStringEncoder.encodeComponent(cookie.getComment(), charset)); } - add(sb, CookieHeaderNames.VERSION, encodingVersion); + add(sb, CookieHeaderNames.VERSION, 1); } if (encodingVersion == 2) { diff --git a/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java b/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java index 25332576cf..bc10811f07 100644 --- a/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/http/CookieEncoderTest.java @@ -66,7 +66,7 @@ public class CookieEncoderTest { } @Test public void testEncodingSingleCookieV2() { - String result = "myCookie=myValue;max-age=50;path=%2Fapathsomewhere;domain=%2Fadomainsomewhere;secure;comment=this%20is%20a%20comment;version=2;commentURL=\"http%2F%3Aaurl.com\";port=\"80,8080\";discard;"; + String result = "myCookie=myValue;max-age=50;path=%2Fapathsomewhere;domain=%2Fadomainsomewhere;secure;comment=this%20is%20a%20comment;version=1;commentURL=\"http%2F%3Aaurl.com\";port=\"80,8080\";discard;"; Cookie cookie = new DefaultCookie("myCookie", "myValue"); CookieEncoder encoder = new CookieEncoder(2); encoder.addCookie(cookie); @@ -84,9 +84,9 @@ public class CookieEncoderTest { @Test public void testEncodingMultipleCookies() { - String c1 = "myCookie=myValue;max-age=50;path=%2Fapathsomewhere;domain=%2Fadomainsomewhere;secure;comment=this%20is%20a%20comment;version=2;commentURL=\"http%2F%3Aaurl.com\";port=\"80,8080\";discard;"; - String c2 = "myCookie2=myValue2;max-age=0;path=%2Fanotherpathsomewhere;domain=%2Fanotherdomainsomewhere;comment=this%20is%20another%20comment;version=2;commentURL=\"http%2F%3Aanotherurl.com\";"; - String c3 = "myCookie3=myValue3;max-age=0;version=2;"; + String c1 = "myCookie=myValue;max-age=50;path=%2Fapathsomewhere;domain=%2Fadomainsomewhere;secure;comment=this%20is%20a%20comment;version=1;commentURL=\"http%2F%3Aaurl.com\";port=\"80,8080\";discard;"; + String c2 = "myCookie2=myValue2;max-age=0;path=%2Fanotherpathsomewhere;domain=%2Fanotherdomainsomewhere;comment=this%20is%20another%20comment;version=1;commentURL=\"http%2F%3Aanotherurl.com\";"; + String c3 = "myCookie3=myValue3;max-age=0;version=1;"; CookieEncoder encoder = new CookieEncoder(2); Cookie cookie = new DefaultCookie("myCookie", "myValue"); cookie.setComment("this is a comment");