mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
serve http: add Last-Modified headers to files and directories
This means that using `rclone serve http` preserves modification times when used with the http backend. Fixes #4201
This commit is contained in:
@@ -138,6 +138,9 @@ func (s *server) serveDir(w http.ResponseWriter, r *http.Request, dirRemote stri
|
||||
orderParm := r.URL.Query().Get("order")
|
||||
directory.ProcessQueryParams(sortParm, orderParm)
|
||||
|
||||
// Set the Last-Modified header to the timestamp
|
||||
w.Header().Set("Last-Modified", dir.ModTime().UTC().Format(http.TimeFormat))
|
||||
|
||||
directory.Serve(w, r)
|
||||
}
|
||||
|
||||
@@ -175,6 +178,9 @@ func (s *server) serveFile(w http.ResponseWriter, r *http.Request, remote string
|
||||
w.Header().Set("Content-Type", mimeType)
|
||||
}
|
||||
|
||||
// Set the Last-Modified header to the timestamp
|
||||
w.Header().Set("Last-Modified", file.ModTime().UTC().Format(http.TimeFormat))
|
||||
|
||||
// If HEAD no need to read the object since we have set the headers
|
||||
if r.Method == "HEAD" {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user