1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

http: add basic metadata and provide it via serve

Co-authored-by: dougal <147946567+roucc@users.noreply.github.com>
This commit is contained in:
Oleg Kunitsyn
2025-11-17 17:52:30 +01:00
committed by GitHub
parent 80e6389a50
commit ecea0cd6f9
9 changed files with 232 additions and 12 deletions

View File

@@ -39,6 +39,26 @@ func Object(w http.ResponseWriter, r *http.Request, o fs.Object) {
modTime := o.ModTime(r.Context())
w.Header().Set("Last-Modified", modTime.UTC().Format(http.TimeFormat))
// Set metadata headers if present
metadata, err := fs.GetMetadata(r.Context(), o)
if err != nil {
fs.Debugf(o, "Request get metadata error: %v", err)
}
if metadata != nil {
if metadata["content-disposition"] != "" {
w.Header().Set("Content-Disposition", metadata["content-disposition"])
}
if metadata["cache-control"] != "" {
w.Header().Set("Cache-Control", metadata["cache-control"])
}
if metadata["content-language"] != "" {
w.Header().Set("Content-Language", metadata["content-language"])
}
if metadata["content-encoding"] != "" {
w.Header().Set("Content-Encoding", metadata["content-encoding"])
}
}
if r.Method == "HEAD" {
return
}