Allow to set Expires attribute to a date in the past. This may break the behavior of old implementations, so it need some notes in the announcement of the version. See #479

This commit is contained in:
norman 2012-07-30 11:13:42 +02:00
parent 5706d6a2ec
commit 236b0da210
3 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ public interface Cookie extends Comparable<Cookie> {
/**
* Sets the max age of this cookie in seconds. If {@code 0} is specified,
* this cookie will be removed by browser because it will be expired
* immediately. If {@code -1} is specified, this cookie will be removed
* immediately. If {@link Integer#MIN_VALUE} is specified, this cookie will be removed
* when a user terminates browser.
*/
void setMaxAge(int maxAge);

View File

@ -107,7 +107,7 @@ public class CookieEncoder {
for (Cookie cookie: cookies) {
add(sb, cookie.getName(), cookie.getValue());
if (cookie.getMaxAge() >= 0) {
if (cookie.getMaxAge() != Integer.MIN_VALUE) {
if (cookie.getVersion() == 0) {
addUnquoted(sb, CookieHeaderNames.EXPIRES,
new CookieDateFormat().format(

View File

@ -35,7 +35,7 @@ public class DefaultCookie implements Cookie {
private boolean discard;
private Set<Integer> ports = Collections.emptySet();
private Set<Integer> unmodifiablePorts = ports;
private int maxAge = -1;
private int maxAge = Integer.MIN_VALUE;
private int version;
private boolean secure;
private boolean httpOnly;