forked from loafle/openapi-generator-original
[Go] use EqualFold instead instead of comparing strings in lower case (#12741)
* use EqualFold instead in the go client * update samples
This commit is contained in:
parent
08108cc4ba
commit
c982421495
@ -111,7 +111,7 @@ func selectHeaderAccept(accepts []string) string {
|
|||||||
// contains is a case insensitive match, finding needle in a haystack
|
// contains is a case insensitive match, finding needle in a haystack
|
||||||
func contains(haystack []string, needle string) bool {
|
func contains(haystack []string, needle string) bool {
|
||||||
for _, a := range haystack {
|
for _, a := range haystack {
|
||||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
if strings.EqualFold(a, needle) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ func (h *HttpSignatureAuth) ContextWithValue(ctx context.Context) (context.Conte
|
|||||||
}
|
}
|
||||||
m := make(map[string]bool)
|
m := make(map[string]bool)
|
||||||
for _, h := range h.SignedHeaders {
|
for _, h := range h.SignedHeaders {
|
||||||
if strings.ToLower(h) == strings.ToLower(HttpHeaderAuthorization) {
|
if strings.EqualFold(h, HttpHeaderAuthorization) {
|
||||||
return nil, fmt.Errorf("Signed headers cannot include the 'Authorization' header")
|
return nil, fmt.Errorf("Signed headers cannot include the 'Authorization' header")
|
||||||
}
|
}
|
||||||
m[h] = true
|
m[h] = true
|
||||||
|
@ -119,7 +119,7 @@ func selectHeaderAccept(accepts []string) string {
|
|||||||
// contains is a case insensitive match, finding needle in a haystack
|
// contains is a case insensitive match, finding needle in a haystack
|
||||||
func contains(haystack []string, needle string) bool {
|
func contains(haystack []string, needle string) bool {
|
||||||
for _, a := range haystack {
|
for _, a := range haystack {
|
||||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
if strings.EqualFold(a, needle) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func selectHeaderAccept(accepts []string) string {
|
|||||||
// contains is a case insensitive match, finding needle in a haystack
|
// contains is a case insensitive match, finding needle in a haystack
|
||||||
func contains(haystack []string, needle string) bool {
|
func contains(haystack []string, needle string) bool {
|
||||||
for _, a := range haystack {
|
for _, a := range haystack {
|
||||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
if strings.EqualFold(a, needle) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ func selectHeaderAccept(accepts []string) string {
|
|||||||
// contains is a case insensitive match, finding needle in a haystack
|
// contains is a case insensitive match, finding needle in a haystack
|
||||||
func contains(haystack []string, needle string) bool {
|
func contains(haystack []string, needle string) bool {
|
||||||
for _, a := range haystack {
|
for _, a := range haystack {
|
||||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
if strings.EqualFold(a, needle) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func (h *HttpSignatureAuth) ContextWithValue(ctx context.Context) (context.Conte
|
|||||||
}
|
}
|
||||||
m := make(map[string]bool)
|
m := make(map[string]bool)
|
||||||
for _, h := range h.SignedHeaders {
|
for _, h := range h.SignedHeaders {
|
||||||
if strings.ToLower(h) == strings.ToLower(HttpHeaderAuthorization) {
|
if strings.EqualFold(h, HttpHeaderAuthorization) {
|
||||||
return nil, fmt.Errorf("Signed headers cannot include the 'Authorization' header")
|
return nil, fmt.Errorf("Signed headers cannot include the 'Authorization' header")
|
||||||
}
|
}
|
||||||
m[h] = true
|
m[h] = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user