From 5b69ad9878be9de800691ff68d24591c612c1277 Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 17 Nov 2025 02:09:20 -0800 Subject: [PATCH] Metadata Header Case --- weed/s3api/s3api_object_handlers.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 5619718b6..ff4ee0e28 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -1756,11 +1756,14 @@ func (s3a *S3ApiServer) setResponseHeaders(w http.ResponseWriter, entry *filer_p // Support backward compatibility: migrate old non-canonical format to canonical format // OLD: "x-amz-meta-foo" → NEW: "X-Amz-Meta-foo" (preserving suffix case) headerKey := k - if len(k) >= 11 && strings.EqualFold(k[:11], "x-amz-meta-") && !strings.HasPrefix(k, s3_constants.AmzUserMetaPrefix) { - // Old format detected - normalize to canonical prefix, preserve suffix case + if len(k) >= 11 && strings.EqualFold(k[:11], "x-amz-meta-") { + // Normalize to AWS S3 format: "X-Amz-Meta-" prefix with lowercase suffix + // AWS S3 returns user metadata with the suffix in lowercase suffix := k[len("x-amz-meta-"):] - headerKey = s3_constants.AmzUserMetaPrefix + suffix - glog.V(4).Infof("Migrating old user metadata header %q to %q in response", k, headerKey) + headerKey = s3_constants.AmzUserMetaPrefix + strings.ToLower(suffix) + if glog.V(4) && k != headerKey { + glog.Infof("Normalizing user metadata header %q to %q in response", k, headerKey) + } } w.Header()[headerKey] = []string{string(v)} }