diff --git a/src/main/java/org/jboss/netty/handler/codec/http/CookieDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/CookieDecoder.java index a5d959b90f..c5509a941d 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/CookieDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/CookieDecoder.java @@ -58,8 +58,8 @@ public class CookieDecoder { Set cookies = new TreeSet(); String[] split = header.split(SEMICOLON); int version = 0; - boolean versionAtTheBeginning = false; for (int i = 0; i < split.length; i++) { + boolean versionAtTheBeginning = false; DefaultCookie theCookie; String s = split[i]; String[] cookie = s.split(EQUALS, 2); diff --git a/src/test/java/org/jboss/netty/handler/codec/http/CookieDecoderTest.java b/src/test/java/org/jboss/netty/handler/codec/http/CookieDecoderTest.java index d68afea54e..b54fd51b2c 100644 --- a/src/test/java/org/jboss/netty/handler/codec/http/CookieDecoderTest.java +++ b/src/test/java/org/jboss/netty/handler/codec/http/CookieDecoderTest.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.Iterator; import java.util.Set; +import org.junit.Ignore; import org.junit.Test; /** @@ -220,6 +221,40 @@ public class CookieDecoderTest { assertNull(c.getDomain()); assertTrue(c.getPorts().isEmpty()); assertEquals(-1, c.getMaxAge()); + } + @Test + @Ignore + public void testDecodingCommaSeparatedClientSideCookies() { + // FIXME Fix CookieDecoder to pass this test. + String source = + "$Version=\"1\"; session_id=\"1234\", " + + "$Version=\"1\"; session_id=\"1111\"; $Domain=\".cracker.edu\""; + + Set cookies = new CookieDecoder().decode(source); + Iterator it = cookies.iterator(); + Cookie c; + + c = it.next(); + assertEquals(1, c.getVersion()); + assertEquals("session_id", c.getName()); + assertEquals("1234", c.getValue()); + assertNull(c.getPath()); + assertNull(c.getComment()); + assertNull(c.getCommentUrl()); + assertNull(c.getDomain()); + assertTrue(c.getPorts().isEmpty()); + assertEquals(-1, c.getMaxAge()); + + c = it.next(); + assertEquals(1, c.getVersion()); + assertEquals("session_id", c.getName()); + assertEquals("1111", c.getValue()); + assertEquals(".cracker.edu", c.getDomain()); + assertNull(c.getPath()); + assertNull(c.getComment()); + assertNull(c.getCommentUrl()); + assertTrue(c.getPorts().isEmpty()); + assertEquals(-1, c.getMaxAge()); } }