[#6440] added a temporary exception for Backblaze S3 endpoints to exclude the new aws-sdk-go-v2 checksum headers

This commit is contained in:
Gani Georgiev
2025-02-10 22:49:10 +02:00
parent 2e26f61cb7
commit c0b7762abd
33 changed files with 149 additions and 126 deletions
+19 -3
View File
@@ -25,6 +25,8 @@ import (
"gocloud.dev/blob"
"gocloud.dev/blob/fileblob"
"gocloud.dev/gcerrors"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
var gcpIgnoreHeaders = []string{"Accept-Encoding"}
@@ -94,11 +96,25 @@ func NewS3(
o.UsePathStyle = s3ForcePathStyle
// Google Cloud Storage alters the Accept-Encoding header,
// which breaks the v2 request signature
// (https://github.com/aws/aws-sdk-go-v2/issues/1816)
if strings.Contains(endpoint, "storage.googleapis.com") {
// Google Cloud Storage alters the Accept-Encoding header,
// which breaks the v2 request signature
// (https://github.com/aws/aws-sdk-go-v2/issues/1816)
ignoreSigningHeaders(o, gcpIgnoreHeaders)
} else if strings.Contains(endpoint, "backblazeb2.com") {
// Backblaze currently doesn't support the new sdk's checksum headers
// (https://www.backblaze.com/docs/cloud-storage-s3-compatible-api#unsupported-features)
o.RequestChecksumCalculation = aws.RequestChecksumCalculationUnset
o.APIOptions = append(o.APIOptions,
smithyhttp.SetHeaderValue("x-amz-checksum-crc32", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-crc32c", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-crc64nvme", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-sha1", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-sha256", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-mode", ""),
smithyhttp.SetHeaderValue("x-amz-checksum-algorithm", ""),
smithyhttp.SetHeaderValue("x-amz-sdk-checksum-algorithm", ""),
)
}
})