make cookie decoder behavior configurable via a constructor argument

This commit is contained in:
Jeff Pinner 2011-11-08 12:03:23 -08:00
parent fae46dabf1
commit 152ea47d48

View File

@ -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<Cookie> cookies = new TreeSet<Cookie>();
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;
}