Allow to set Expires attribute

to a date in theast. See #479
This commit is contained in:
norman 2012-07-30 07:44:53 +02:00
parent 9b37de32a0
commit bdde5a20f6
3 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ public interface Cookie extends Comparable<Cookie> {
void setComment(String comment);
/**
* Returns the maximum age of this {@link Cookie} in seconds.
* Returns the maximum age of this {@link Cookie} in seconds or {@link Long#MIN_VALUE} if unspecified
*
* @return The maximum age of this {@link Cookie}
*/
@ -97,7 +97,7 @@ public interface Cookie extends Comparable<Cookie> {
* Sets the maximum age of this {@link Cookie} in seconds.
* If an age of {@code 0} is specified, this {@link Cookie} will be
* automatically removed by browser because it will expire immediately.
* If {@code -1} is specified, this {@link Cookie} will be removed when the
* If {@link Long#MIN_VALUE} is specified, this {@link Cookie} will be removed when the
* browser is closed.
*
* @param maxAge The maximum age of this {@link Cookie} in seconds

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 long maxAge = -1;
private long maxAge = Long.MIN_VALUE;
private int version;
private boolean secure;
private boolean httpOnly;

View File

@ -54,7 +54,7 @@ public final class ServerCookieEncoder {
add(buf, cookie.getName(), cookie.getValue());
if (cookie.getMaxAge() >= 0) {
if (cookie.getMaxAge() != Long.MIN_VALUE) {
if (cookie.getVersion() == 0) {
addUnquoted(buf, CookieHeaderNames.EXPIRES,
new HttpHeaderDateFormat().format(