Merge pull request #592 from harshavardhana/pr_out_fix_signature_calculation_bug
This commit is contained in:
@@ -84,7 +84,7 @@ func (a *s3Client) getTLSTransport() (*http.Transport, error) {
|
||||
func (a *s3Client) signRequest(req *http.Request, host string) {
|
||||
hm := hmac.New(sha1.New, []byte(a.SecretAccessKey))
|
||||
ss := a.stringToSign(req, host)
|
||||
//fmt.Printf("String to sign: %q (%x)\n", ss, ss)
|
||||
//DEBUG - fmt.Printf("String to sign: %q (%x)\n", ss, ss)
|
||||
io.WriteString(hm, ss)
|
||||
|
||||
authHeader := new(bytes.Buffer)
|
||||
@@ -195,11 +195,6 @@ var subResList = []string{
|
||||
// <HTTP-Request-URI, from the protocol name up to the query string> +
|
||||
// [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
|
||||
func (a *s3Client) writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request, host string) {
|
||||
bucket, _ := a.url2BucketAndObject()
|
||||
if bucket != "" {
|
||||
buf.WriteByte('/')
|
||||
buf.WriteString(bucket)
|
||||
}
|
||||
buf.WriteString(req.URL.Path)
|
||||
sort.Strings(subResList)
|
||||
if req.URL.RawQuery != "" {
|
||||
|
||||
@@ -41,13 +41,7 @@ func (c *s3Client) url2BucketAndObject() (bucketName, objectName string) {
|
||||
}
|
||||
|
||||
func (c *s3Client) getBucketRequestURL(bucket string) string {
|
||||
// default to path style
|
||||
url := fmt.Sprintf("%s://%s/%s", c.Scheme, c.Host, bucket)
|
||||
if strings.Contains(c.Host, "amazonaws.com") {
|
||||
// amazonaws.com use subdomain style
|
||||
url = fmt.Sprintf("%s://%s.%s", c.Scheme, bucket, c.Host)
|
||||
}
|
||||
return url
|
||||
return fmt.Sprintf("%s://%s/%s", c.Scheme, c.Host, bucket)
|
||||
}
|
||||
|
||||
// getObjectRequestURL constructs a URL using bucket and object
|
||||
|
||||
Reference in New Issue
Block a user