1
0
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:
Harshavardhana
2015-04-27 04:28:37 -07:00
parent f0842dbb6d
commit 877d32236c
4 changed files with 3 additions and 5 deletions

View File

@@ -97,7 +97,7 @@ func runListCmd(ctx *cli.Context) {
err = iodine.New(err, nil)
if err != nil {
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))
}
}
}

View File

@@ -82,9 +82,6 @@ func (a *s3Client) getTLSTransport() (*http.Transport, error) {
}
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))
ss := a.stringToSign(req, host)
//fmt.Printf("String to sign: %q (%x)\n", ss, ss)

View File

@@ -124,9 +124,9 @@ func (s *MySuite) TestsignRequest(c *C) {
Transport: http.DefaultTransport,
}, url,
}
r.Header.Set("Date", "Sat, 02 Apr 2011 04:23:52 GMT")
cl.signRequest(r, "localhost:9000")
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")
c.Assert(r.Header.Get("Authorization"), Equals, "AWS key:kHpCR/N7Rw3PwRlDd8+5X40CFVc=")
}

View File

@@ -151,6 +151,7 @@ func (c *s3Client) newRequest(method, url string, body io.ReadCloser) (*http.Req
return nil, iodine.New(err, errParams)
}
req.Header.Set("User-Agent", c.UserAgent)
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
return req, nil
}