From de29d56dbe0109d285b588b4aac5bfcc93e03acd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 10 Sep 2024 16:00:24 -0400 Subject: [PATCH] 21702: Fix behavior of COPY with depth 0. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- services/keep-web/handler.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go index c82b3b6b39..a6e15d5ae0 100644 --- a/services/keep-web/handler.go +++ b/services/keep-web/handler.go @@ -680,7 +680,23 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { if len(dsttarget) == len(dsturl.Path) { http.Error(w, "destination path not supported", http.StatusBadRequest) } - replace[strings.TrimSuffix(dsttarget, "/")] = "current/" + colltarget + dsttarget = strings.TrimSuffix(dsttarget, "/") + if r.Method == "COPY" && strings.HasSuffix(dsturl.Path, "/") && r.Header.Get("Depth") == "0" { + // rfc4918 9.8.3: A COPY of "Depth: 0" + // only instructs that the collection + // and its properties, but not + // resources identified by its + // internal member URLs, are to be + // copied. + // + // rfc4918 9.9.2: A client MUST NOT + // submit a Depth header on a MOVE on + // a collection with any value but + // "infinity". + replace[dsttarget] = "manifest_text/" + } else { + replace[dsttarget] = "current/" + colltarget + } if r.Method == "MOVE" { replace["/"+colltarget] = "" } -- 2.30.2