public CookieAttribute[] getOptions() { List<CookieAttribute> options = newArrayList(); if (this.path != null) { options.add(CookieAttribute.path(this.path)); } if (this.domain != null) { options.add(CookieAttribute.domain(this.domain)); } if (this.secure) { options.add(CookieAttribute.secure()); } if (this.httpOnly) { options.add(CookieAttribute.httpOnly()); } if (this.maxAge != null) { options.add(CookieAttribute.maxAge(this.maxAge.getLatency(), this.maxAge.getUnit())); } return options.toArray(new CookieAttribute[options.size()]); }
@Test public void should_set_and_recognize_cookie_with_secure() throws Exception { server.request(eq(cookie("loggedIn"), "true")).response(status(200)); server.response(cookie("loggedIn", "true", secure()), status(302)); running(server, new Runnable() { @Override public void run() throws IOException { org.apache.http.HttpResponse response = helper.getResponse(root()); String value = response.getFirstHeader(HttpHeaders.SET_COOKIE).getValue(); Cookie decodeCookie = ClientCookieDecoder.STRICT.decode(value); assertThat(decodeCookie.isSecure(), is(true)); } }); }
public final CookieAttribute[] getOptions() { List<CookieAttribute> options = newArrayList(); if (this.path != null) { options.add(CookieAttribute.path(this.path)); } if (this.domain != null) { options.add(CookieAttribute.domain(this.domain)); } if (this.secure) { options.add(CookieAttribute.secure()); } if (this.httpOnly) { options.add(CookieAttribute.httpOnly()); } if (this.maxAge != null) { options.add(CookieAttribute.maxAge(this.maxAge.getLatency(), this.maxAge.getUnit())); } return options.toArray(new CookieAttribute[options.size()]); }