diff options
Diffstat (limited to 'vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go')
-rw-r--r-- | vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go b/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go deleted file mode 100644 index 9fc5df9..0000000 --- a/vendor/github.com/aws/aws-sdk-go/service/s3/content_md5.go +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | package s3 | ||
2 | |||
3 | import ( | ||
4 | "crypto/md5" | ||
5 | "encoding/base64" | ||
6 | "io" | ||
7 | |||
8 | "github.com/aws/aws-sdk-go/aws/awserr" | ||
9 | "github.com/aws/aws-sdk-go/aws/request" | ||
10 | ) | ||
11 | |||
12 | // contentMD5 computes and sets the HTTP Content-MD5 header for requests that | ||
13 | // require it. | ||
14 | func contentMD5(r *request.Request) { | ||
15 | h := md5.New() | ||
16 | |||
17 | // hash the body. seek back to the first position after reading to reset | ||
18 | // the body for transmission. copy errors may be assumed to be from the | ||
19 | // body. | ||
20 | _, err := io.Copy(h, r.Body) | ||
21 | if err != nil { | ||
22 | r.Error = awserr.New("ContentMD5", "failed to read body", err) | ||
23 | return | ||
24 | } | ||
25 | _, err = r.Body.Seek(0, 0) | ||
26 | if err != nil { | ||
27 | r.Error = awserr.New("ContentMD5", "failed to seek body", err) | ||
28 | return | ||
29 | } | ||
30 | |||
31 | // encode the md5 checksum in base64 and set the request header. | ||
32 | sum := h.Sum(nil) | ||
33 | sum64 := make([]byte, base64.StdEncoding.EncodedLen(len(sum))) | ||
34 | base64.StdEncoding.Encode(sum64, sum) | ||
35 | r.HTTPRequest.Header.Set("Content-MD5", string(sum64)) | ||
36 | } | ||