diff --git a/lib/go/camli/misc/amazon/s3/auth.go b/lib/go/camli/misc/amazon/s3/auth.go index 6e1aa52d2..ebcd20ad3 100644 --- a/lib/go/camli/misc/amazon/s3/auth.go +++ b/lib/go/camli/misc/amazon/s3/auth.go @@ -23,11 +23,14 @@ import ( "fmt" "http" "io" + "log" "sort" "strings" "time" ) +var _ = log.Printf + // See http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html type Auth struct { @@ -40,7 +43,8 @@ func (a *Auth) SignRequest(req *http.Request) { req.Header.Set("Date", time.UTC().Format(http.TimeFormat)) } hm := hmac.NewSHA1([]byte(a.SecretAccessKey)) - io.WriteString(hm, stringToSign(req)) + ss := stringToSign(req) + io.WriteString(hm, ss) authHeader := new(bytes.Buffer) fmt.Fprintf(authHeader, "AWS %s:", a.AccessKey) @@ -148,6 +152,9 @@ const standardUSRegionAWS = "s3.amazonaws.com" func bucketFromHostname(req *http.Request) string { host := req.Host + if host == "" { + host = req.URL.Host + } if host == standardUSRegionAWS { return "" }