/** * Adds a new {@link Cookie} created with the specified name and value to * this encoder. */ public void addCookie(String name, String value) { cookies.add(new DefaultCookie(name, value)); }
DefaultCookie cookie = new DefaultCookie(name, unwrappedValue.toString()); cookie.setWrap(wrap); return cookie;
@Override public NettyHttpResponse cookie(HttpCookie httpCookie) { Cookie nettyCookie = new DefaultCookie(httpCookie.getName(),httpCookie.getValue()); nettyCookie.setDomain(httpCookie.getDomain()); nettyCookie.setPath(httpCookie.getPath()); nettyCookie.setSecure(httpCookie.getSecure()); nettyCookie.setMaxAge((int)httpCookie.getMaxAge()); nettyCookie.setVersion(httpCookie.getVersion()); nettyCookie.setDiscard(httpCookie.getDiscard()); nettyCookie.setHttpOnly(true); CookieEncoder encoder = new CookieEncoder(true); encoder.addCookie(nettyCookie); return header(HttpHeaders.Names.SET_COOKIE, encoder.encode()); }
@Override public NettyHttpResponse cookie(HttpCookie httpCookie) { Cookie nettyCookie = new DefaultCookie(httpCookie.getName(),httpCookie.getValue()); nettyCookie.setDomain(httpCookie.getDomain()); nettyCookie.setPath(httpCookie.getPath()); nettyCookie.setSecure(httpCookie.getSecure()); nettyCookie.setMaxAge((int)httpCookie.getMaxAge()); nettyCookie.setVersion(httpCookie.getVersion()); nettyCookie.setDiscard(httpCookie.getDiscard()); nettyCookie.setHttpOnly(true); CookieEncoder encoder = new CookieEncoder(true); encoder.addCookie(nettyCookie); return header(HttpHeaders.Names.SET_COOKIE, encoder.encode()); }