@Test public void testSetCookie() throws ProtocolException { String setCookie1 = "SID=31d4d96e407aad42; Domain=example.com; Path=/"; List<HttpCookie> cookies = setCookieDecoder.decode(setCookie1.getBytes()); Assert.assertEquals(1, cookies.size()); for (HttpCookie cookie : cookies) { LOG.debug(new String(encoder.encode(cookie))); } String setCookie2 = "SID=31d4d96e407aad42; Domain=example.com; Path=/chat; HttpOnly; Secure; Expires=Wed, 09 Jun 2021 10:18:14 GMT; Max-Age=86400; test=extensionTest"; cookies = setCookieDecoder.decode(setCookie2.getBytes()); Assert.assertEquals(1, cookies.size()); for (HttpCookie cookie : cookies) { Assert.assertEquals("SID", cookie.getName()); Assert.assertEquals("31d4d96e407aad42", cookie.getValue()); Assert.assertEquals("example.com", cookie.getDomain()); Assert.assertEquals("/chat", cookie.getPath()); Assert.assertEquals(true, cookie.isHttpOnly().booleanValue()); Assert.assertEquals(true, cookie.isSecure().booleanValue()); Assert.assertEquals("Wed, 09 Jun 2021 10:18:14 GMT", HttpDates.format(cookie.getExpires())); Assert.assertEquals(86400, cookie.getMaxAge().intValue()); Assert.assertEquals("extensionTest", cookie.getExtensionAttribute("test")); LOG.debug(new String(encoder.encode(cookie))); } System.out.println(String.format("[CRAFT-ATOM-PROTOCOL-HTTP] (^_^) <%s> Case -> test set cookie. ", CaseCounter.incr(2))); }
@Override public List<HttpCookie> decode(byte[] bytes) throws ProtocolException { try { if (setCookie) { return decode4setCookie(bytes); } else { return decode4cookie(bytes); } } catch (Exception e) { if (e instanceof ProtocolException) { throw (ProtocolException) e; } throw new ProtocolException(e); } }
HttpCookieDecoder extends AbstractProtocolCodec implements ProtocolDecoder<HttpCookie> { @Override public List<HttpCookie> decode(byte[] bytes) throws ProtocolException { try { if (setCookie) { return decode4setCookie(bytes); } else { return decode4cookie(bytes); } } catch (Exception e) { if (e instanceof ProtocolException) { throw (ProtocolException) e; } throw new ProtocolException(e); } } }
HttpCookieDecoder extends AbstractProtocolCodec implements ProtocolDecoder<HttpCookie> { @Override public List<HttpCookie> decode(byte[] bytes) throws ProtocolException { try { if (setCookie) { return decode4setCookie(bytes); } else { return decode4cookie(bytes); } } catch (Exception e) { if (e instanceof ProtocolException) { throw (ProtocolException) e; } throw new ProtocolException(e); } } HttpCookieDecoder();  HttpCookieDecoder(Charset charset);  HttpCookieDecoder(Charset charset, boolean setCookie); }
HttpCookieDecoder extends AbstractProtocolCodec implements ProtocolDecoder<HttpCookie> { @Override public List<HttpCookie> decode(byte[] bytes) throws ProtocolException { try { if (setCookie) { return decode4setCookie(bytes); } else { return decode4cookie(bytes); } } catch (Exception e) { if (e instanceof ProtocolException) { throw (ProtocolException) e; } throw new ProtocolException(e); } } HttpCookieDecoder();  HttpCookieDecoder(Charset charset);  HttpCookieDecoder(Charset charset, boolean setCookie); @Override void reset(); @Override List<HttpCookie> decode(byte[] bytes); }
HttpCookieDecoder extends AbstractProtocolCodec implements ProtocolDecoder<HttpCookie> { @Override public List<HttpCookie> decode(byte[] bytes) throws ProtocolException { try { if (setCookie) { return decode4setCookie(bytes); } else { return decode4cookie(bytes); } } catch (Exception e) { if (e instanceof ProtocolException) { throw (ProtocolException) e; } throw new ProtocolException(e); } } HttpCookieDecoder();  HttpCookieDecoder(Charset charset);  HttpCookieDecoder(Charset charset, boolean setCookie); @Override void reset(); @Override List<HttpCookie> decode(byte[] bytes);  }