From 152ea47d48a77beeb9bdc6a8595509af6707bf96 Mon Sep 17 00:00:00 2001 From: Jeff Pinner Date: Tue, 8 Nov 2011 12:03:23 -0800 Subject: [PATCH] make cookie decoder behavior configurable via a constructor argument --- .../handler/codec/http/CookieDecoder.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 e1e5e01bbd..0a090313bd 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 @@ -50,11 +50,22 @@ public class CookieDecoder { private final static String COMMA = ","; + private boolean lenient; + /** - * Creates a new decoder. + * Creates a new decoder with strict parsing. */ public CookieDecoder() { - super(); + this(false); + } + + /** + * Creates a new decoder. + * + * @param lenient ignores cookies with the name 'HTTPOnly' instead of throwing an exception + */ + public CookieDecoder(boolean lenient) { + this.lenient = lenient; } /** @@ -95,8 +106,8 @@ public class CookieDecoder { Set cookies = new TreeSet(); for (; i < names.size(); i ++) { String name = names.get(i); - // Not all user agents understand the HttpOnly attribute -- be lenient - if (CookieHeaderNames.HTTPONLY.equalsIgnoreCase(name)) { + // Not all user agents understand the HttpOnly attribute + if (lenient && CookieHeaderNames.HTTPONLY.equalsIgnoreCase(name)) { continue; }