diff --git a/.changelog/2ab6aa4259a34a4d966c84b440837c93.json b/.changelog/2ab6aa4259a34a4d966c84b440837c93.json new file mode 100644 index 00000000000..727e2a56d05 --- /dev/null +++ b/.changelog/2ab6aa4259a34a4d966c84b440837c93.json @@ -0,0 +1,8 @@ +{ + "id": "2ab6aa42-59a3-4a4d-966c-84b440837c93", + "type": "bugfix", + "description": "refactoring of buildQuery to accept a map of hand maintained headers to lowercase because of an S3 limitation", + "modules": [ + "." + ] +} \ No newline at end of file diff --git a/aws/signer/v4/v4.go b/aws/signer/v4/v4.go index dcd896a9bf6..7ed91d5bac1 100644 --- a/aws/signer/v4/v4.go +++ b/aws/signer/v4/v4.go @@ -394,11 +394,16 @@ func (s *httpSigner) buildCredentialScope() string { func buildQuery(r v4Internal.Rule, header http.Header) (url.Values, http.Header) { query := url.Values{} unsignedHeaders := http.Header{} + + // A list of headers to be converted to lower case to mitigate a limitation from S3 + lowerCaseHeaders := map[string]string{ + "X-Amz-Expected-Bucket-Owner": "x-amz-expected-bucket-owner", // see #2508 + "X-Amz-Request-Payer": "x-amz-request-payer", // see #2764 + } + for k, h := range header { - // literally just this header has this constraint for some stupid reason, - // see #2508 - if k == "X-Amz-Expected-Bucket-Owner" { - k = "x-amz-expected-bucket-owner" + if newKey, ok := lowerCaseHeaders[k]; ok { + k = newKey } if r.IsValid(k) {