|
@ -29,7 +29,7 @@ var ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// 需要校验的 Headers 列表
|
|
|
// 需要校验的 Headers 列表
|
|
|
var needSignHeaders = map[string]bool{ |
|
|
|
|
|
|
|
|
var NeedSignHeaders = map[string]bool{ |
|
|
"host": true, |
|
|
"host": true, |
|
|
"range": true, |
|
|
"range": true, |
|
|
"x-cos-acl": true, |
|
|
"x-cos-acl": true, |
|
@ -65,6 +65,10 @@ var ciParameters = map[string]bool{ |
|
|
"imageview2/": true, |
|
|
"imageview2/": true, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func SetNeedSignHeaders(key string, val bool) { |
|
|
|
|
|
NeedSignHeaders[key] = val |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func safeURLEncode(s string) string { |
|
|
func safeURLEncode(s string) string { |
|
|
s = encodeURIComponent(s) |
|
|
s = encodeURIComponent(s) |
|
|
s = strings.Replace(s, "!", "%21", -1) |
|
|
s = strings.Replace(s, "!", "%21", -1) |
|
@ -275,7 +279,7 @@ func isCIParameter(key string) bool { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func isSignHeader(key string) bool { |
|
|
func isSignHeader(key string) bool { |
|
|
for k, v := range needSignHeaders { |
|
|
|
|
|
|
|
|
for k, v := range NeedSignHeaders { |
|
|
if key == k && v { |
|
|
if key == k && v { |
|
|
return true |
|
|
return true |
|
|
} |
|
|
} |
|
|