Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
index 62f075c73c..5a27be6430 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java
@@ -54,6 +54,7 @@ import static org.eclipse.jgit.util.HttpSupport.HDR_LAST_MODIFIED;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.time.Instant;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -76,7 +77,9 @@ abstract class ObjectFileServlet extends HttpServlet {
@Override
String etag(FileSender sender) throws IOException {
- return Long.toHexString(sender.getLastModified());
+ Instant lastModified = sender.getLastModified();
+ return Long.toHexString(lastModified.getEpochSecond())
+ + Long.toHexString(lastModified.getNano());
}
}
@@ -145,7 +148,9 @@ abstract class ObjectFileServlet extends HttpServlet {
try {
final String etag = etag(sender);
- final long lastModified = (sender.getLastModified() / 1000) * 1000;
+ // HTTP header Last-Modified header has a resolution of 1 sec, see
+ // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29
+ final long lastModified = sender.getLastModified().getEpochSecond();
String ifNoneMatch = req.getHeader(HDR_IF_NONE_MATCH);
if (etag != null && etag.equals(ifNoneMatch)) {

Back to the top