From 9c356e550af97effe699b5058dbbdab1b2f33d9e Mon Sep 17 00:00:00 2001 From: Giuseppe Lo Presti Date: Thu, 2 Jun 2022 12:11:47 +0200 Subject: [PATCH] On HEAD requests and when available, expose checksum values using the standard header on top of the ownCloud-specific one --- changelog/unreleased/gfal-cksum.md | 10 ++++++++++ internal/http/services/owncloud/ocdav/head.go | 1 + internal/http/services/owncloud/ocdav/webdav.go | 1 + 3 files changed, 12 insertions(+) create mode 100644 changelog/unreleased/gfal-cksum.md diff --git a/changelog/unreleased/gfal-cksum.md b/changelog/unreleased/gfal-cksum.md new file mode 100644 index 0000000000..1e3a6196fe --- /dev/null +++ b/changelog/unreleased/gfal-cksum.md @@ -0,0 +1,10 @@ +Enhancement: Use standard header for checksums + +On HEAD requests, we currently expose checksums (when available) using the +ownCloud-specific header, which is typically consumed by the sync clients. + +This patch adds the standard Digest header using the standard format +detailed at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Digest. +This is e.g. used by GFAL/Rucio clients in the context of managed transfers of datasets. + +https://github.com/cs3org/reva/pull/2921 diff --git a/internal/http/services/owncloud/ocdav/head.go b/internal/http/services/owncloud/ocdav/head.go index 7acdca6a8e..88b03379eb 100644 --- a/internal/http/services/owncloud/ocdav/head.go +++ b/internal/http/services/owncloud/ocdav/head.go @@ -78,6 +78,7 @@ func (s *svc) handleHead(ctx context.Context, w http.ResponseWriter, r *http.Req w.Header().Set(HeaderOCETag, info.Etag) if info.Checksum != nil { w.Header().Set(HeaderOCChecksum, fmt.Sprintf("%s:%s", strings.ToUpper(string(storageprovider.GRPC2PKGXS(info.Checksum.Type))), info.Checksum.Sum)) + w.Header().Set(HeaderChecksum, fmt.Sprintf("%s=%s", strings.ToLower(string(storageprovider.GRPC2PKGXS(info.Checksum.Type))), info.Checksum.Sum)) } t := utils.TSToTime(info.Mtime).UTC() lastModifiedString := t.Format(time.RFC1123Z) diff --git a/internal/http/services/owncloud/ocdav/webdav.go b/internal/http/services/owncloud/ocdav/webdav.go index b33ff86898..8ad8f1333d 100644 --- a/internal/http/services/owncloud/ocdav/webdav.go +++ b/internal/http/services/owncloud/ocdav/webdav.go @@ -51,6 +51,7 @@ const ( HeaderLocation = "Location" HeaderRange = "Range" HeaderIfMatch = "If-Match" + HeaderChecksum = "Digest" ) // Non standard HTTP headers.