From f7b78cd8349e0a1c7c6770f238874ad226038524 Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 9 Feb 2025 00:36:49 +0100 Subject: [PATCH] fix: support HEAD method on collections --- lib/handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/handler.go b/lib/handler.go index e22b893..eeaa3fd 100644 --- a/lib/handler.go +++ b/lib/handler.go @@ -146,8 +146,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // "index.html" resource, a human-readable view of the contents of // the collection, or something else altogether. // + // Similarly, since the definition of HEAD is a GET without a response + // message body, the semantics of HEAD are unmodified when applied to + // collection resources. + // // Get, when applied to collection, will return the same as PROPFIND method. - if r.Method == "GET" && strings.HasPrefix(r.URL.Path, user.Prefix) { + if (r.Method == "GET" || r.Method == "HEAD") && strings.HasPrefix(r.URL.Path, user.Prefix) { info, err := user.FileSystem.Stat(r.Context(), strings.TrimPrefix(r.URL.Path, user.Prefix)) if err == nil && info.IsDir() { r.Method = "PROPFIND"