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.

This commit is contained in:
jinhuiyanga 2023-09-17 19:33:51 +08:00
parent 7a3c3d7939
commit 0c2acbae2e
2 changed files with 2 additions and 2 deletions

View File

@ -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)

View File

@ -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)