|
|
@ -1015,25 +1015,20 @@ func newTestRequest(method, urlStr string, contentLength int64, body io.ReadSeek |
|
|
|
return req, nil |
|
|
|
return req, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func newTestSignedRequestV2ContentType(method, urlStr string, contentLength int64, body io.ReadSeeker, accessKey, secretKey, contentType string) (*http.Request, error) { |
|
|
|
// Various signature types we are supporting, currently
|
|
|
|
req, err := newTestRequest(method, urlStr, contentLength, body) |
|
|
|
// two main signature types.
|
|
|
|
if err != nil { |
|
|
|
type signerType int |
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
req.Header.Del("x-amz-content-sha256") |
|
|
|
|
|
|
|
req.Header.Set("Content-Type", contentType) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Anonymous request return quickly.
|
|
|
|
const ( |
|
|
|
if accessKey == "" || secretKey == "" { |
|
|
|
signerV2 signerType = iota |
|
|
|
return req, nil |
|
|
|
signerV4 |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
err = signRequestV2(req, accessKey, secretKey) |
|
|
|
func newTestSignedRequest(method, urlStr string, contentLength int64, body io.ReadSeeker, accessKey, secretKey string, signer signerType) (*http.Request, error) { |
|
|
|
if err != nil { |
|
|
|
if signer == signerV2 { |
|
|
|
return nil, err |
|
|
|
return newTestSignedRequestV2(method, urlStr, contentLength, body, accessKey, secretKey) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return newTestSignedRequestV4(method, urlStr, contentLength, body, accessKey, secretKey) |
|
|
|
return req, nil |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Returns new HTTP request object signed with signature v2.
|
|
|
|
// Returns new HTTP request object signed with signature v2.
|
|
|
|