@Test public void okResponse() throws Exception { final Content content = new Content(new StringPayload(payloadString, "text/plain")); content.getAttributes().set(Content.CONTENT_LAST_MODIFIED, now); content.getAttributes().set(Content.CONTENT_ETAG, "etag"); when(context.proceed()).thenReturn(HttpResponses.ok(content)); final Response r = subject.handle(context); assertThat(r.getStatus().isSuccessful(), is(true)); assertThat(r.getHeaders().get(HttpHeaders.LAST_MODIFIED), equalTo(DateTimeUtils.formatDateTime(now))); assertThat(r.getHeaders().get(HttpHeaders.ETAG), equalTo("\"etag\"")); }
@Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { final Response response = context.proceed(); Payload payload = response.getPayload(); if (response.getStatus().isSuccessful() && payload instanceof Content) { final Content content = (Content) payload; final DateTime lastModified = content.getAttributes().get(Content.CONTENT_LAST_MODIFIED, DateTime.class); if (lastModified != null) { response.getHeaders().set(HttpHeaders.LAST_MODIFIED, formatDateTime(lastModified)); } final String etag = content.getAttributes().get(Content.CONTENT_ETAG, String.class); if (etag != null) { response.getHeaders().set(HttpHeaders.ETAG, ETagHeaderUtils.quote(etag)); } } return response; }
ContentHeadersHandler extends ComponentSupport implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { final Response response = context.proceed(); Payload payload = response.getPayload(); if (response.getStatus().isSuccessful() && payload instanceof Content) { final Content content = (Content) payload; final DateTime lastModified = content.getAttributes().get(Content.CONTENT_LAST_MODIFIED, DateTime.class); if (lastModified != null) { response.getHeaders().set(HttpHeaders.LAST_MODIFIED, formatDateTime(lastModified)); } final String etag = content.getAttributes().get(Content.CONTENT_ETAG, String.class); if (etag != null) { response.getHeaders().set(HttpHeaders.ETAG, ETagHeaderUtils.quote(etag)); } } return response; } }
ContentHeadersHandler extends ComponentSupport implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { final Response response = context.proceed(); Payload payload = response.getPayload(); if (response.getStatus().isSuccessful() && payload instanceof Content) { final Content content = (Content) payload; final DateTime lastModified = content.getAttributes().get(Content.CONTENT_LAST_MODIFIED, DateTime.class); if (lastModified != null) { response.getHeaders().set(HttpHeaders.LAST_MODIFIED, formatDateTime(lastModified)); } final String etag = content.getAttributes().get(Content.CONTENT_ETAG, String.class); if (etag != null) { response.getHeaders().set(HttpHeaders.ETAG, ETagHeaderUtils.quote(etag)); } } return response; }  }
ContentHeadersHandler extends ComponentSupport implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { final Response response = context.proceed(); Payload payload = response.getPayload(); if (response.getStatus().isSuccessful() && payload instanceof Content) { final Content content = (Content) payload; final DateTime lastModified = content.getAttributes().get(Content.CONTENT_LAST_MODIFIED, DateTime.class); if (lastModified != null) { response.getHeaders().set(HttpHeaders.LAST_MODIFIED, formatDateTime(lastModified)); } final String etag = content.getAttributes().get(Content.CONTENT_ETAG, String.class); if (etag != null) { response.getHeaders().set(HttpHeaders.ETAG, ETagHeaderUtils.quote(etag)); } } return response; }  @Nonnull @Override Response handle(@Nonnull final Context context); }
ContentHeadersHandler extends ComponentSupport implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { final Response response = context.proceed(); Payload payload = response.getPayload(); if (response.getStatus().isSuccessful() && payload instanceof Content) { final Content content = (Content) payload; final DateTime lastModified = content.getAttributes().get(Content.CONTENT_LAST_MODIFIED, DateTime.class); if (lastModified != null) { response.getHeaders().set(HttpHeaders.LAST_MODIFIED, formatDateTime(lastModified)); } final String etag = content.getAttributes().get(Content.CONTENT_ETAG, String.class); if (etag != null) { response.getHeaders().set(HttpHeaders.ETAG, ETagHeaderUtils.quote(etag)); } } return response; }  @Nonnull @Override Response handle(@Nonnull final Context context);  }