@@ -411,13 +411,10 @@ func RegisterHandlers(engine *gin.Engine, directorEnabled bool) error {
411411 wildcardPath := c .Param ("path" )
412412
413413 if c .Request .Method == http .MethodHead {
414- // For HEAD requests, create a modified request with just the wildcard path
415- // since handleHeadWithChecksum handles the response directly
416- modifiedReq := c .Request .Clone (c .Request .Context ())
417- modifiedURL := * c .Request .URL
418- modifiedURL .Path = wildcardPath
419- modifiedReq .URL = & modifiedURL
420- handleHeadWithChecksum (c , handler , modifiedReq , wildcardPath , storagePrefix )
414+ // For HEAD requests, pass the original request to the WebDAV handler
415+ // (it needs the full URL so its Prefix stripping works correctly).
416+ // wildcardPath is used only for checksum lookup on the filesystem.
417+ handleHeadWithChecksum (c , handler , c .Request , wildcardPath , storagePrefix )
421418 } else {
422419 // For all other methods (including PROPFIND), pass the original request
423420 // to the WebDAV handler. The handler's Prefix field ensures it strips
@@ -447,7 +444,7 @@ func RegisterHandlers(engine *gin.Engine, directorEnabled bool) error {
447444}
448445
449446// handleHeadWithChecksum handles HEAD requests and adds checksum headers per RFC 3230
450- func handleHeadWithChecksum (c * gin.Context , handler * webdav.Handler , modifiedReq * http.Request , relativePath string , storagePrefix string ) {
447+ func handleHeadWithChecksum (c * gin.Context , handler * webdav.Handler , req * http.Request , relativePath string , storagePrefix string ) {
451448 // Check if client requested checksums via Want-Digest header
452449 wantDigest := c .GetHeader ("Want-Digest" )
453450 if wantDigest == "" {
@@ -504,5 +501,5 @@ func handleHeadWithChecksum(c *gin.Context, handler *webdav.Handler, modifiedReq
504501 }
505502
506503 // Now let the WebDAV handler process the HEAD request
507- handler .ServeHTTP (c .Writer , modifiedReq )
504+ handler .ServeHTTP (c .Writer , req )
508505}
0 commit comments