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:
parent
5706d6a2ec
commit
236b0da210
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user