Skip to content
This repository has been archived by the owner on Aug 14, 2018. It is now read-only.

Fixes for S3 signature generation. #32

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ func stringToSignS3(request *http.Request) string {

if request.Header.Get("Content-Md5") != "" {
str += request.Header.Get("Content-Md5")
} else {
body := readAndReplaceBody(request)
if len(body) > 0 {
str += hashMD5(body)
}
}
str += "\n"

Expand Down Expand Up @@ -86,7 +81,17 @@ func canonicalResourceS3(request *http.Request) string {
res += "/" + bucketname
}

res += request.URL.Path
uri := request.URL.Opaque
if uri != "" {
uri = "/" + strings.Join(strings.Split(uri, "/")[3:], "/")
} else {
uri = request.URL.Path
}
if uri == "" {
uri = "/"
}

res += uri

for _, subres := range strings.Split(subresourcesS3, ",") {
if strings.HasPrefix(request.URL.RawQuery, subres) {
Expand Down