fix(webdav): Handle HEAD requests for directories with appropriate headers (#1015)

Implement handling of HEAD requests for directories by setting the correct Content-Type and Content-Length headers.
This commit is contained in:
Suyunjing
2025-08-09 13:57:09 +08:00
committed by GitHub
parent ab747d9052
commit aa0ced47b0

View File

@ -233,6 +233,11 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
return http.StatusNotFound, err
}
if fi.IsDir() {
if r.Method == http.MethodHead {
w.Header().Set("Content-Type", "httpd/unix-directory")
w.Header().Set("Content-Length", "0")
return http.StatusOK, nil
}
return http.StatusMethodNotAllowed, nil
}
// Let ServeContent determine the Content-Type header.