From 8f6aa65a10ebce53320ce0a727999e4b970f7c37 Mon Sep 17 00:00:00 2001 From: x3 Date: Wed, 28 Feb 2024 00:25:27 +0100 Subject: [PATCH] Return 304 if If-Modified-Since header is present in download --- controller/download.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/controller/download.go b/controller/download.go index 528c242..f640224 100644 --- a/controller/download.go +++ b/controller/download.go @@ -19,6 +19,15 @@ func Download(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + + ifModifH := r.Header.Get("If-Modified-Since") + if ifModifH != "" { + // Is (probably) not modified, send back 304 + log.Printf("Download (%s): got If-Modified-Since, replying 304\n", id) + w.WriteHeader(http.StatusNotModified) + return + } + d1 := file.Sha1Sum[0:2] d2 := file.Sha1Sum[2:4]