From 0c2acbae2ef3927a5eedeeb85c3b7a3927bba82f Mon Sep 17 00:00:00 2001 From: jinhuiyanga <15880578252@163.com> Date: Sun, 17 Sep 2023 19:33:51 +0800 Subject: [PATCH] fix:go's net/HTTP standard library is widely used. Note that by default, it uses CanonicalHeaderKey mode to handle the received and requested Header Names. --- pkg/common/db/s3/cos/cos.go | 2 +- pkg/common/db/s3/oss/oss.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/common/db/s3/cos/cos.go b/pkg/common/db/s3/cos/cos.go index 57a205cbe..d6b1961b9 100644 --- a/pkg/common/db/s3/cos/cos.go +++ b/pkg/common/db/s3/cos/cos.go @@ -185,7 +185,7 @@ func (c *Cos) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, erro if res.ETag = strings.ToLower(strings.ReplaceAll(info.Header.Get("ETag"), `"`, "")); res.ETag == "" { return nil, errors.New("StatObject etag not found") } - if contentLengthStr := info.Header.Get("Content-Length"); contentLengthStr == "" { + if contentLengthStr := info.Header.Get(http.CanonicalHeaderKey("Content-Length")); contentLengthStr == "" { return nil, errors.New("StatObject content-length not found") } else { res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64) diff --git a/pkg/common/db/s3/oss/oss.go b/pkg/common/db/s3/oss/oss.go index 384ce8093..dab5c2f1d 100644 --- a/pkg/common/db/s3/oss/oss.go +++ b/pkg/common/db/s3/oss/oss.go @@ -188,7 +188,7 @@ func (o *OSS) StatObject(ctx context.Context, name string) (*s3.ObjectInfo, erro if res.ETag = strings.ToLower(strings.ReplaceAll(header.Get("ETag"), `"`, ``)); res.ETag == "" { return nil, errors.New("StatObject etag not found") } - if contentLengthStr := header.Get("Content-Length"); contentLengthStr == "" { + if contentLengthStr := header.Get(http.CanonicalHeaderKey("Content-Length")); contentLengthStr == "" { return nil, errors.New("StatObject content-length not found") } else { res.Size, err = strconv.ParseInt(contentLengthStr, 10, 64)