mirror of
https://github.com/minio/minio.git
synced 2025-11-20 01:50:24 -05:00
etag: add FromContentMD5 to parse content-md5 as ETag (#11688)
This commit adds the `FromContentMD5` function to parse a client-provided content-md5 as ETag. Further, it also adds multipart ETag computation for future needs.
This commit is contained in:
committed by
GitHub
parent
2c198ae7b6
commit
f14cc6c943
13
cmd/utils.go
13
cmd/utils.go
@@ -20,7 +20,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
@@ -143,18 +142,6 @@ func xmlDecoder(body io.Reader, v interface{}, size int64) error {
|
||||
return d.Decode(v)
|
||||
}
|
||||
|
||||
// checkValidMD5 - verify if valid md5, returns md5 in bytes.
|
||||
func checkValidMD5(h http.Header) ([]byte, error) {
|
||||
md5B64, ok := h[xhttp.ContentMD5]
|
||||
if ok {
|
||||
if md5B64[0] == "" {
|
||||
return nil, fmt.Errorf("Content-Md5 header set to empty value")
|
||||
}
|
||||
return base64.StdEncoding.Strict().DecodeString(md5B64[0])
|
||||
}
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
// hasContentMD5 returns true if Content-MD5 header is set.
|
||||
func hasContentMD5(h http.Header) bool {
|
||||
_, ok := h[xhttp.ContentMD5]
|
||||
|
||||
Reference in New Issue
Block a user