Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring of buildQuery to accept a list of maintained headers to l… #2773

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading