Skip to content

Commit

Permalink
refactoring of buildQuery to accept a list of maintained headers to l… (
Browse files Browse the repository at this point in the history
  • Loading branch information
RanVaknin authored Sep 3, 2024
1 parent 4ed838e commit 3120376
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .changelog/2ab6aa4259a34a4d966c84b440837c93.json
Original file line number Diff line number Diff line change
@@ -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": [
"."
]
}
13 changes: 9 additions & 4 deletions aws/signer/v4/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3120376

Please sign in to comment.