List of usage examples for io.netty.handler.codec.http.cookie ClientCookieDecoder STRICT
ClientCookieDecoder STRICT
To view the source code for io.netty.handler.codec.http.cookie ClientCookieDecoder STRICT.
Click Source Link
From source file:com.github.mcollovati.vertx.vaadin.CookieUtils.java
License:Open Source License
static Cookie fromVertxCookie(io.vertx.ext.web.Cookie cookie) { io.netty.handler.codec.http.cookie.Cookie decoded = ClientCookieDecoder.STRICT.decode(cookie.encode()); Cookie out = new Cookie(decoded.name(), decoded.value()); Optional.ofNullable(decoded.domain()).ifPresent(out::setDomain); out.setPath(decoded.path());//from w w w . j a v a 2s . c o m out.setHttpOnly(decoded.isHttpOnly()); out.setSecure(decoded.isSecure()); if (decoded.maxAge() != Long.MIN_VALUE) { out.setMaxAge((int) decoded.maxAge()); } // TODO extract other values return out; }
From source file:reactor.ipc.netty.http.Cookies.java
License:Open Source License
public Map<CharSequence, Set<Cookie>> getCachedCookies() { if (!STATE.compareAndSet(this, NOT_READ, READING)) { for (;;) { if (state == READ) { return cachedCookies; }/*from w ww. j av a 2 s. com*/ } } List<String> allCookieHeaders = nettyHeaders.getAll(cookiesHeaderName); Map<String, Set<Cookie>> cookies = new HashMap<>(); for (String aCookieHeader : allCookieHeaders) { Set<Cookie> decode; if (isClientChannel) { final Cookie c = ClientCookieDecoder.STRICT.decode(aCookieHeader); Set<Cookie> existingCookiesOfName = cookies.get(c.name()); if (null == existingCookiesOfName) { existingCookiesOfName = new HashSet<>(); cookies.put(c.name(), existingCookiesOfName); } existingCookiesOfName.add(c); } else { decode = ServerCookieDecoder.STRICT.decode(aCookieHeader); for (Cookie cookie : decode) { Set<Cookie> existingCookiesOfName = cookies.get(cookie.name()); if (null == existingCookiesOfName) { existingCookiesOfName = new HashSet<>(); cookies.put(cookie.name(), existingCookiesOfName); } existingCookiesOfName.add(cookie); } } } cachedCookies = Collections.unmodifiableMap(cookies); state = READ; return cachedCookies; }