From 25e012d30b3746015e2c41a2137ef8522dec8d12 Mon Sep 17 00:00:00 2001 From: famosss Date: Tue, 25 Oct 2022 08:29:52 +0800 Subject: [PATCH] fix: set user metadata key to lowercase (#3894) * fix: set user metadata key to lowercase * feat: simplify a bit --- weed/s3api/s3api_object_handlers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index 8c4e3f0e8..37851b147 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -409,10 +409,22 @@ func (s3a *S3ApiServer) proxyToFiler(w http.ResponseWriter, r *http.Request, des return } + setUserMetadataKeyToLowercase(resp) + responseStatusCode := responseFn(resp, w) s3err.PostLog(r, responseStatusCode, s3err.ErrNone) } +func setUserMetadataKeyToLowercase(resp *http.Response) { + for key, value := range resp.Header { + if strings.HasPrefix(key, s3_constants.AmzUserMetaPrefix) { + resp.Header[strings.ToLower(key)] = value + delete(resp.Header,key) + continue + } + } +} + func passThroughResponse(proxyResponse *http.Response, w http.ResponseWriter) (statusCode int) { for k, v := range proxyResponse.Header { w.Header()[k] = v