mirror of
https://github.com/minio/mc.git
synced 2025-11-13 12:22:45 +03:00
Make sure to set the Date's properly in s3Client
This commit is contained in:
@@ -97,7 +97,7 @@ func runListCmd(ctx *cli.Context) {
|
|||||||
err = iodine.New(err, nil)
|
err = iodine.New(err, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug.Println(err)
|
log.Debug.Println(err)
|
||||||
console.Fatalln("Failed to list [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
console.Fatalf("Failed to list [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,9 +82,6 @@ func (a *s3Client) getTLSTransport() (*http.Transport, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *s3Client) signRequest(req *http.Request, host string) {
|
func (a *s3Client) signRequest(req *http.Request, host string) {
|
||||||
if date := req.Header.Get("Date"); date == "" {
|
|
||||||
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
|
||||||
}
|
|
||||||
hm := hmac.New(sha1.New, []byte(a.SecretAccessKey))
|
hm := hmac.New(sha1.New, []byte(a.SecretAccessKey))
|
||||||
ss := a.stringToSign(req, host)
|
ss := a.stringToSign(req, host)
|
||||||
//fmt.Printf("String to sign: %q (%x)\n", ss, ss)
|
//fmt.Printf("String to sign: %q (%x)\n", ss, ss)
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ func (s *MySuite) TestsignRequest(c *C) {
|
|||||||
Transport: http.DefaultTransport,
|
Transport: http.DefaultTransport,
|
||||||
}, url,
|
}, url,
|
||||||
}
|
}
|
||||||
|
r.Header.Set("Date", "Sat, 02 Apr 2011 04:23:52 GMT")
|
||||||
cl.signRequest(r, "localhost:9000")
|
cl.signRequest(r, "localhost:9000")
|
||||||
c.Assert(r.Header.Get("Date"), Not(Equals), "")
|
c.Assert(r.Header.Get("Date"), Not(Equals), "")
|
||||||
r.Header.Set("Date", "Sat, 02 Apr 2011 04:23:52 GMT")
|
|
||||||
cl.signRequest(r, "localhost:9000")
|
cl.signRequest(r, "localhost:9000")
|
||||||
c.Assert(r.Header.Get("Authorization"), Equals, "AWS key:kHpCR/N7Rw3PwRlDd8+5X40CFVc=")
|
c.Assert(r.Header.Get("Authorization"), Equals, "AWS key:kHpCR/N7Rw3PwRlDd8+5X40CFVc=")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ func (c *s3Client) newRequest(method, url string, body io.ReadCloser) (*http.Req
|
|||||||
return nil, iodine.New(err, errParams)
|
return nil, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", c.UserAgent)
|
req.Header.Set("User-Agent", c.UserAgent)
|
||||||
|
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user