List of usage examples for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE
long UNDEFINED_MAX_AGE
To view the source code for io.netty.handler.codec.http.cookie Cookie UNDEFINED_MAX_AGE.
Click Source Link
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)); }