-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aws: Add config option to unmarshal API response header maps to norma…
…lized lower case map keys (#3033)
- Loading branch information
Showing
12 changed files
with
267 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
### SDK Features | ||
|
||
### SDK Enhancements | ||
* `aws`: Add configuration option enable the SDK to unmarshal API response header maps to normalized lower case map keys. ([#3033](https://github.com/aws/aws-sdk-go/pull/3033)) | ||
* Setting `aws.Config.LowerCaseHeaderMaps` to `true` will result in S3's X-Amz-Meta prefixed header to be unmarshaled to lower case Metadata member's map keys. | ||
|
||
### SDK Bugs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package strings | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// HasPrefixFold tests whether the string s begins with prefix, interpreted as UTF-8 strings, | ||
// under Unicode case-folding. | ||
func HasPrefixFold(s, prefix string) bool { | ||
return len(s) >= len(prefix) && strings.EqualFold(s[0:len(prefix)], prefix) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// +build go1.7 | ||
|
||
package strings | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestHasPrefixFold(t *testing.T) { | ||
type args struct { | ||
s string | ||
prefix string | ||
} | ||
tests := map[string]struct { | ||
args args | ||
want bool | ||
}{ | ||
"empty strings and prefix": { | ||
args: args{ | ||
s: "", | ||
prefix: "", | ||
}, | ||
want: true, | ||
}, | ||
"strings starts with prefix": { | ||
args: args{ | ||
s: "some string", | ||
prefix: "some", | ||
}, | ||
want: true, | ||
}, | ||
"prefix longer then string": { | ||
args: args{ | ||
s: "some", | ||
prefix: "some string", | ||
}, | ||
}, | ||
"equal length string and prefix": { | ||
args: args{ | ||
s: "short string", | ||
prefix: "short string", | ||
}, | ||
want: true, | ||
}, | ||
"different cases": { | ||
args: args{ | ||
s: "ShOrT StRING", | ||
prefix: "short", | ||
}, | ||
want: true, | ||
}, | ||
"empty prefix not empty string": { | ||
args: args{ | ||
s: "ShOrT StRING", | ||
prefix: "", | ||
}, | ||
want: true, | ||
}, | ||
"mixed-case prefixes": { | ||
args: args{ | ||
s: "SoMe String", | ||
prefix: "sOme", | ||
}, | ||
want: true, | ||
}, | ||
} | ||
for name, tt := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
if got := HasPrefixFold(tt.args.s, tt.args.prefix); got != tt.want { | ||
t.Errorf("HasPrefixFold() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func BenchmarkHasPrefixFold(b *testing.B) { | ||
HasPrefixFold("SoME string", "sOmE") | ||
} | ||
|
||
func BenchmarkHasPrefix(b *testing.B) { | ||
strings.HasPrefix(strings.ToLower("SoME string"), strings.ToLower("sOmE")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.