Fixed faulty cache response.
authorFredrik Tolf <fredrik@dolda2000.com>
Tue, 13 Oct 2009 19:10:02 +0000 (21:10 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Tue, 13 Oct 2009 19:10:02 +0000 (21:10 +0200)
src/dolda/jsvc/util/Cache.java

index 6fd7d7a..0021336 100644 (file)
@@ -8,7 +8,7 @@ public class Cache {
        /* Since the HTTP time format is (reasonably enough) precise
         * only to seconds, any extra milliseconds must be trimmed
         * off, or the mtime will almost certainly not match. */
-       Date mdate = new Date((mtime / 1000) * 1000);
+       final Date mdate = new Date((mtime / 1000) * 1000);
        String ims = req.inheaders().get("If-Modified-Since");
        if(ims != null) {
            Date cldate;
@@ -18,9 +18,13 @@ public class Cache {
                throw(Restarts.stdresponse(400, "The If-Modified-Since header is not parseable."));
            }
            if(mdate.compareTo(cldate) <= 0) {
-               req.status(304);
-               req.outheaders().put("Content-Length", "0");
-               throw(Restarts.done());
+               throw(new RequestRestart() {
+                       public void respond(Request req) {
+                           req.status(304);
+                           req.outheaders().put("Content-Length", "0");
+                           req.outheaders().put("Last-Modified", Http.fmtdate(mdate));
+                       }
+                   });
            }
        }
        req.outheaders().put("Last-Modified", Http.fmtdate(mdate));