Merge pull request #50 from jpinner/ignore_httponly_cookies_3.2

Ignore httponly cookies 3.2
This commit is contained in:
Norman Maurer 2011-11-09 10:11:13 -08:00
commit 582b25eaf5

View File

@ -50,11 +50,22 @@ public class CookieDecoder {
private final static String COMMA = ",";
private final 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,6 +106,11 @@ 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
if (lenient && CookieHeaderNames.HTTPONLY.equalsIgnoreCase(name)) {
continue;
}
String value = values.get(i);
if (value == null) {
value = "";