Example usage for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE

List of usage examples for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE

Introduction

In this page you can find the example usage for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE.

Prototype

long UNDEFINED_MAX_AGE

To view the source code for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE.

Click Source Link

Document

Constant for undefined MaxAge attribute value.

Usage

From source file:org.asynchttpclient.cookie.ThreadSafeCookieStore.java

License:Open Source License

private boolean hasCookieExpired(Cookie cookie, long whenCreated) {
    // if not specify max-age, this cookie should be discarded when user agent is to be closed, but it is not expired.
    if (cookie.maxAge() == Cookie.UNDEFINED_MAX_AGE)
        return false;

    if (cookie.maxAge() <= 0)
        return true;

    if (whenCreated > 0) {
        long deltaSecond = (System.currentTimeMillis() - whenCreated) / 1000;
        return deltaSecond > cookie.maxAge();
    } else//www.j a v  a 2  s  .  com
        return false;
}

From source file:org.asynchttpclient.cookie.ThreadSafeCookieStore.java

License:Open Source License

private void add(String requestDomain, String requestPath, Cookie cookie) {

    AbstractMap.SimpleEntry<String, Boolean> pair = cookieDomain(cookie.domain(), requestDomain);
    String keyDomain = pair.getKey();
    boolean hostOnly = pair.getValue();
    String keyPath = cookiePath(cookie.path(), requestPath);
    CookieKey key = new CookieKey(cookie.name().toLowerCase(), keyDomain, keyPath);

    if (hasCookieExpired(cookie, 0))
        cookieJar.remove(key);/* w  ww. j av  a2s .com*/
    else
        cookieJar.put(key, new StoredCookie(cookie, hostOnly, cookie.maxAge() != Cookie.UNDEFINED_MAX_AGE));
}