ResponseHandler { CookieImpl cookie(CookieSpec spec, String value) { var cookie = new CookieImpl(spec.name); if (value == null) { cookie.setMaxAge(0); cookie.setValue(""); } else { if (spec.maxAge != null) cookie.setMaxAge((int) spec.maxAge.getSeconds()); cookie.setValue(Encodings.uriComponent(value)); } cookie.setDomain(spec.domain); cookie.setPath(spec.path); cookie.setSecure(spec.secure); cookie.setHttpOnly(spec.httpOnly); if (spec.sameSite) cookie.setSameSiteMode(CookieSameSiteMode.LAX.toString()); return cookie; } ResponseHandler(ResponseBeanWriter writer, TemplateManager templateManager, SessionManager sessionManager); void render(RequestImpl request, ResponseImpl response, HttpServerExchange exchange, ActionLog actionLog);  }
@Test void cookie() { CookieImpl cookie = responseHandler.cookie(new CookieSpec("test").secure().sameSite(), "1=2"); assertThat(cookie.getName()).isEqualTo("test"); assertThat(cookie.getValue()).isEqualTo("1%3D2"); assertThat(cookie.getSameSiteMode()).isEqualTo("Lax"); }