Beispiel #1
0
 private Response set(final Request request, final Response response, final Cookie cookie) {
   if (cookieAlreadyHasSameValue(request, cookie)
       || (isEmptyJson(cookie.value()) && !request.cookies().contains(FLASH_COOKIE))) {
     return response;
   }
   return response.cookie(cookie);
 }
 @Test
 public void addsAuthorizeHeader() throws Exception {
   RecordingHttpHandler server = recordingHttpHandler();
   HttpClient client = new BasicHttpClient(server, credential("dan", "correct"));
   client.handle(Request.get("/"));
   assertThat(
       server.lastRequest().headers().getValue(HttpHeaders.AUTHORIZATION),
       is("Basic ZGFuOmNvcnJlY3Q="));
 }
Beispiel #3
0
  private static void setIncomingFlashValues(Request request, Flash flash) {
    CookieParameters requestCookies = request.cookies();

    if (!requestCookies.contains(FLASH_COOKIE)
        || isEmptyJson(requestCookies.getValue(FLASH_COOKIE))
        || isBlank(requestCookies.getValue(FLASH_COOKIE))) return;

    flash.merge(Json.parseMap(requestCookies.getValue(FLASH_COOKIE)).value());
  }
Beispiel #4
0
 private boolean cookieAlreadyHasSameValue(final Request request, final Cookie cookie) {
   return cookie.value().equals(request.cookies().getValue(FLASH_COOKIE));
 }