drive: rewrite LOCK paths

Fixes #12097

Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
Percy Wegmann
2024-05-14 20:30:02 -05:00
committed by Percy Wegmann
parent 87f00d76c4
commit 59848fe14b
6 changed files with 380 additions and 87 deletions

View File

@@ -93,8 +93,15 @@ var cacheInvalidatingMethods = map[string]bool{
// ServeHTTP implements http.Handler.
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method == "PROPFIND" {
h.handlePROPFIND(w, r)
pathComponents := shared.CleanAndSplit(r.URL.Path)
mpl := h.maxPathLength(r)
switch r.Method {
case "PROPFIND":
h.handlePROPFIND(w, r, pathComponents, mpl)
return
case "LOCK":
h.handleLOCK(w, r, pathComponents, mpl)
return
}
@@ -107,9 +114,6 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.StatCache.invalidate()
}
mpl := h.maxPathLength(r)
pathComponents := shared.CleanAndSplit(r.URL.Path)
if len(pathComponents) >= mpl {
h.delegate(mpl, pathComponents[mpl-1:], w, r)
return
@@ -141,6 +145,8 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
// delegate sends the request to the Child WebDAV server.
func (h *Handler) delegate(mpl int, pathComponents []string, w http.ResponseWriter, r *http.Request) {
rewriteIfHeader(r, pathComponents, mpl)
dest := r.Header.Get("Destination")
if dest != "" {
// Rewrite destination header