Skip to content

Commit

Permalink
Merge pull request #139 from stesla/master
Browse files Browse the repository at this point in the history
return empty content for 304 (fixes #138)
  • Loading branch information
clonezone committed Jan 8, 2015
2 parents 1781db1 + 319f18a commit f628a7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Expand Up @@ -162,6 +162,7 @@ protected byte[] fileBytes() throws IOException {
if (request.header("If-Modified-Since") != null) {
if (fromHeader(request.header("If-Modified-Since")).getTime() >= lastModified.getTime() ) {
response.status(304);
return new byte[]{};
}
}
//is setting cache control necessary?
Expand Down
Expand Up @@ -217,6 +217,7 @@ public void shouldHandleCacheHeaders() throws Exception {
assertEquals(true, handle(request("/index_cache.html")).header("Expires") != null);
assertEquals(true, handleWithHeader(request("/index_cache.html"), "If-Modified-Since", toDateHeader(new Date(aYearAgo))).status() == 200);
assertEquals(true, handleWithHeader(request("/index_cache.html"), "If-Modified-Since", toDateHeader(new Date(aYearFromNow))).status() == 304);
assertEquals(0, handleWithHeader(request("/index_cache.html"), "If-Modified-Since", toDateHeader(new Date(aYearFromNow))).contents().length);
}

@Test
Expand Down

0 comments on commit f628a7a

Please sign in to comment.