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.

pull/1091/head
jinhuiyanga 2 years ago
parent 7a3c3d7939
commit 0c2acbae2e

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

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

Loading…
Cancel
Save