Return 304 if If-Modified-Since header is present in download

This commit is contained in:
x3 2024-02-28 00:25:27 +01:00
parent bbcf77abde
commit 8f6aa65a10
Signed by: x3
GPG Key ID: 7E9961E8AD0E240E
1 changed files with 9 additions and 0 deletions

View File

@ -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]