HttpHeadersImpl implements HttpHeaders { @Override public Map<String, Cookie> getCookies() { List<String> values = nettyHttpHeaders.getAll(HttpHeaders.COOKIE); if (values == null || values.isEmpty()) { return Collections.emptyMap(); } Map<String, Cookie> cookieMap = new HashMap<>(); for (String value : values) { if (value == null) { continue; } Cookie cookie = Cookie.valueOf(value); cookieMap.put(cookie.getName(), cookie); } return cookieMap; } HttpHeadersImpl(io.netty.handler.codec.http.HttpHeaders httpHeaders); @Override List<String> getRequestHeader(String name); @Override String getHeaderString(String name); @Override MultivaluedMap<String, String> getRequestHeaders(); @Override List<MediaType> getAcceptableMediaTypes(); @Override List<Locale> getAcceptableLanguages(); @Override MediaType getMediaType(); @Override Locale getLanguage(); @Override Map<String, Cookie> getCookies(); @Override Date getDate(); @Override int getLength();  }
@Test public void testGetCookies() throws Exception { Map<String, Cookie> cookieMap = httpHeaders1.getCookies(); assertNotNull(cookieMap); assertEquals(cookieMap.size(), 1); assertTrue(cookieMap.containsKey("JSESSIONID")); assertEquals(cookieMap.get("JSESSIONID").getValue(), "3508015E4EF0ECA8C4B761FCC4BC1718"); Map<String, Cookie> cookieMap2 = httpHeaders2.getCookies(); assertEquals(cookieMap2.size(), 0); }