List of usage examples for io.netty.handler.codec.http Cookie setMaxAge
@Deprecated @Override void setMaxAge(long maxAge);
From source file:fr.wseduc.webutils.request.CookieHelper.java
License:Apache License
public static void set(String name, String value, long timeout, String path, HttpServerRequest request) { Cookie cookie = new DefaultCookie(name, value); cookie.setMaxAge(timeout); cookie.setSecure("https".equals(Renders.getScheme(request))); if (path != null && !path.trim().isEmpty()) { cookie.setPath(path);/*from w w w . j av a2 s. co m*/ } request.response().headers().set("Set-Cookie", ServerCookieEncoder.encode(cookie)); }
From source file:fr.wseduc.webutils.request.CookieHelper.java
License:Apache License
public void setSigned(String name, String value, long timeout, String path, HttpServerRequest request) { Cookie cookie = new DefaultCookie(name, value); cookie.setMaxAge(timeout); cookie.setSecure("https".equals(Renders.getScheme(request))); if (path != null && !path.trim().isEmpty()) { cookie.setPath(path);// www . j a v a2s .com } if (signKey != null) { try { signCookie(cookie); } catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException | UnsupportedEncodingException e) { log.error(e); return; } request.response().headers().set("Set-Cookie", ServerCookieEncoder.encode(cookie)); } }
From source file:io.nebo.container.NettyHttpServletRequest.java
License:Apache License
@Override public Cookie[] getCookies() { String cookieString = this.request.headers().get(COOKIE); if (cookieString != null) { Set<io.netty.handler.codec.http.Cookie> cookies = CookieDecoder.decode(cookieString); if (!cookies.isEmpty()) { Cookie[] cookiesArray = new Cookie[cookies.size()]; int index = 0; for (io.netty.handler.codec.http.Cookie c : cookies) { Cookie cookie = new Cookie(c.getName(), c.getValue()); cookie.setComment(c.getComment()); if (c.getDomain() != null) cookie.setDomain(c.getDomain()); cookie.setMaxAge((int) c.getMaxAge()); cookie.setPath(c.getPath()); cookie.setSecure(c.isSecure()); cookie.setVersion(c.getVersion()); cookiesArray[index] = cookie; index++;//from w w w . j a v a 2 s .co m } return cookiesArray; } } return new Cookie[0]; }
From source file:org.glowroot.local.ui.HttpSessionManager.java
License:Apache License
void deleteSessionCookie(HttpResponse response) { Cookie cookie = new DefaultCookie("GLOWROOT_SESSION_ID", ""); cookie.setHttpOnly(true);// ww w .ja v a2 s . com cookie.setMaxAge(0); cookie.setPath("/"); response.headers().add(SET_COOKIE, ServerCookieEncoder.encode(cookie)); }
From source file:org.ratpackframework.http.internal.DefaultResponse.java
License:Apache License
public Cookie expireCookie(String name) { Cookie cookie = cookie(name, ""); cookie.setMaxAge(0); return cookie; }