Update minio-go-legacy, now mc fully supports Google Cloud Storage - fixes #1185
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Minio Go Library for Amazon S3 Legacy v2 Signature Compatible Cloud Storage [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
# Minio Go Library for Amazon S3 Legacy Signature v2 Compatible Cloud Storage [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
+19
-11
@@ -209,10 +209,16 @@ func (a apiCore) getBucketACL(bucket string) (accessControlPolicy, error) {
|
||||
if err != nil {
|
||||
return accessControlPolicy{}, err
|
||||
}
|
||||
|
||||
// In-case of google private bucket policy doesn't have any Grant list
|
||||
if a.config.Region == "google" {
|
||||
return policy, nil
|
||||
}
|
||||
|
||||
if policy.AccessControlList.Grant == nil {
|
||||
errorResponse := ErrorResponse{
|
||||
Code: "InternalError",
|
||||
Message: "Access control Grant list is empty, please report this at https://github.com/minio/minio-go-legacy/issues",
|
||||
Message: "Access control Grant list is empty, please report this at https://github.com/minio/minio-go-legacy/issues.",
|
||||
Resource: separator + bucket,
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
@@ -371,7 +377,7 @@ func (a apiCore) headBucket(bucket string) error {
|
||||
case http.StatusForbidden:
|
||||
errorResponse = ErrorResponse{
|
||||
Code: "AccessDenied",
|
||||
Message: "Access Denied",
|
||||
Message: "Access Denied.",
|
||||
Resource: separator + bucket,
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
@@ -434,7 +440,7 @@ func (a apiCore) deleteBucket(bucket string) error {
|
||||
case http.StatusForbidden:
|
||||
errorResponse = ErrorResponse{
|
||||
Code: "AccessDenied",
|
||||
Message: "Access Denied",
|
||||
Message: "Access Denied.",
|
||||
Resource: separator + bucket,
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
@@ -498,7 +504,7 @@ func (a apiCore) putObjectUnAuthenticated(bucket, object, contentType string, si
|
||||
}
|
||||
|
||||
// putObjectRequest wrapper creates a new PutObject request
|
||||
func (a apiCore) putObjectRequest(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.ReadSeeker) (*request, error) {
|
||||
func (a apiCore) putObjectRequest(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.Reader) (*request, error) {
|
||||
if strings.TrimSpace(contentType) == "" {
|
||||
contentType = "application/octet-stream"
|
||||
}
|
||||
@@ -512,7 +518,9 @@ func (a apiCore) putObjectRequest(bucket, object, contentType string, md5SumByte
|
||||
return nil, err
|
||||
}
|
||||
// set Content-MD5 as base64 encoded md5
|
||||
r.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5SumBytes))
|
||||
if md5SumBytes != nil {
|
||||
r.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5SumBytes))
|
||||
}
|
||||
r.Set("Content-Type", contentType)
|
||||
r.req.ContentLength = size
|
||||
return r, nil
|
||||
@@ -520,7 +528,7 @@ func (a apiCore) putObjectRequest(bucket, object, contentType string, md5SumByte
|
||||
|
||||
// putObject - add an object to a bucket
|
||||
// NOTE: You must have WRITE permissions on a bucket to add an object to it.
|
||||
func (a apiCore) putObject(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.ReadSeeker) (ObjectStat, error) {
|
||||
func (a apiCore) putObject(bucket, object, contentType string, md5SumBytes []byte, size int64, body io.Reader) (ObjectStat, error) {
|
||||
req, err := a.putObjectRequest(bucket, object, contentType, md5SumBytes, size, body)
|
||||
if err != nil {
|
||||
return ObjectStat{}, err
|
||||
@@ -657,7 +665,7 @@ func (a apiCore) getObject(bucket, object string, offset, length int64) (io.Read
|
||||
if err != nil {
|
||||
return nil, ObjectStat{}, ErrorResponse{
|
||||
Code: "InternalError",
|
||||
Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues",
|
||||
Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues.",
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
}
|
||||
@@ -789,7 +797,7 @@ func (a apiCore) headObject(bucket, object string) (ObjectStat, error) {
|
||||
case http.StatusForbidden:
|
||||
errorResponse = ErrorResponse{
|
||||
Code: "AccessDenied",
|
||||
Message: "Access Denied",
|
||||
Message: "Access Denied.",
|
||||
Resource: separator + bucket + separator + object,
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
@@ -812,7 +820,7 @@ func (a apiCore) headObject(bucket, object string) (ObjectStat, error) {
|
||||
if err != nil {
|
||||
return ObjectStat{}, ErrorResponse{
|
||||
Code: "InternalError",
|
||||
Message: "Content-Length not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues",
|
||||
Message: "Content-Length not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues.",
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
}
|
||||
@@ -821,7 +829,7 @@ func (a apiCore) headObject(bucket, object string) (ObjectStat, error) {
|
||||
if err != nil {
|
||||
return ObjectStat{}, ErrorResponse{
|
||||
Code: "InternalError",
|
||||
Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues",
|
||||
Message: "Last-Modified time format not recognized, please report this issue at https://github.com/minio/minio-go-legacy/issues.",
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
}
|
||||
@@ -868,7 +876,7 @@ func (a apiCore) listBuckets() (listAllMyBucketsResult, error) {
|
||||
if resp.StatusCode == http.StatusTemporaryRedirect {
|
||||
return listAllMyBucketsResult{}, ErrorResponse{
|
||||
Code: "AccessDenied",
|
||||
Message: "Anonymous access is forbidden for this operation",
|
||||
Message: "Anonymous access is forbidden for this operation.",
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
HostID: resp.Header.Get("x-amz-id-2"),
|
||||
}
|
||||
|
||||
+6
-4
@@ -228,7 +228,7 @@ func (a apiCore) abortMultipartUpload(bucket, object, uploadID string) error {
|
||||
default:
|
||||
errorResponse = ErrorResponse{
|
||||
Code: resp.Status,
|
||||
Message: "",
|
||||
Message: "Unknown error, please report this at https://github.com/minio/minio-go-legacy/issues.",
|
||||
Resource: separator + bucket + separator + object,
|
||||
RequestID: resp.Header.Get("x-amz-request-id"),
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func (a apiCore) listObjectParts(bucket, object, uploadID string, partNumberMark
|
||||
}
|
||||
|
||||
// uploadPartRequest wrapper creates a new UploadPart request
|
||||
func (a apiCore) uploadPartRequest(bucket, object, uploadID string, md5SumBytes []byte, partNumber int, size int64, body io.ReadSeeker) (*request, error) {
|
||||
func (a apiCore) uploadPartRequest(bucket, object, uploadID string, md5SumBytes []byte, partNumber int, size int64, body io.Reader) (*request, error) {
|
||||
op := &operation{
|
||||
HTTPServer: a.config.Endpoint,
|
||||
HTTPMethod: "PUT",
|
||||
@@ -299,13 +299,15 @@ func (a apiCore) uploadPartRequest(bucket, object, uploadID string, md5SumBytes
|
||||
return nil, err
|
||||
}
|
||||
// set Content-MD5 as base64 encoded md5
|
||||
r.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5SumBytes))
|
||||
if md5SumBytes != nil {
|
||||
r.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5SumBytes))
|
||||
}
|
||||
r.req.ContentLength = size
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// uploadPart uploads a part in a multipart upload.
|
||||
func (a apiCore) uploadPart(bucket, object, uploadID string, md5SumBytes []byte, partNumber int, size int64, body io.ReadSeeker) (completePart, error) {
|
||||
func (a apiCore) uploadPart(bucket, object, uploadID string, md5SumBytes []byte, partNumber int, size int64, body io.Reader) (completePart, error) {
|
||||
req, err := a.uploadPartRequest(bucket, object, uploadID, md5SumBytes, partNumber, size, body)
|
||||
if err != nil {
|
||||
return completePart{}, err
|
||||
|
||||
+59
-8
@@ -149,6 +149,9 @@ var regions = map[string]string{
|
||||
"s3-ap-northeast-1.amazonaws.com": "ap-northeast-1",
|
||||
"s3-sa-east-1.amazonaws.com": "sa-east-1",
|
||||
"s3.cn-north-1.amazonaws.com.cn": "cn-north-1",
|
||||
|
||||
// Add google cloud storage as one of the regions
|
||||
"storage.googleapis.com": "google",
|
||||
}
|
||||
|
||||
// getRegion returns a region based on its endpoint mapping.
|
||||
@@ -228,8 +231,14 @@ func New(config Config) (API, error) {
|
||||
if err != nil {
|
||||
return api{}, err
|
||||
}
|
||||
match, _ := filepath.Match("*.s3*.amazonaws.com", u.Host)
|
||||
if match {
|
||||
matchS3, _ := filepath.Match("*.s3*.amazonaws.com", u.Host)
|
||||
if matchS3 {
|
||||
config.isVirtualStyle = true
|
||||
hostSplits := strings.SplitN(u.Host, ".", 2)
|
||||
u.Host = hostSplits[1]
|
||||
}
|
||||
matchGoogle, _ := filepath.Match("*.storage.googleapis.com", u.Host)
|
||||
if matchGoogle {
|
||||
config.isVirtualStyle = true
|
||||
hostSplits := strings.SplitN(u.Host, ".", 2)
|
||||
u.Host = hostSplits[1]
|
||||
@@ -333,7 +342,7 @@ var maxConcurrentQueue int64 = 4
|
||||
// storage it will have the following parameters as constants
|
||||
//
|
||||
// maxParts
|
||||
// maximumPartSize
|
||||
// maxiPartSize
|
||||
// minimumPartSize
|
||||
//
|
||||
// if a the partSize after division with maxParts is greater than minimumPartSize
|
||||
@@ -400,7 +409,7 @@ func (a api) newObjectUpload(bucket, object, contentType string, size int64, dat
|
||||
return
|
||||
}
|
||||
var complPart completePart
|
||||
complPart, err = a.uploadPart(bucket, object, uploadID, p.MD5Sum, p.Num, p.Len, p.ReadSeeker)
|
||||
complPart, err = a.uploadPart(bucket, object, uploadID, p.MD5Sum, p.Num, p.Len, p.Reader)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
@@ -541,7 +550,7 @@ func (a api) continueObjectUpload(bucket, object, uploadID string, size int64, d
|
||||
errCh <- p.Err
|
||||
return
|
||||
}
|
||||
completedPart, err := a.uploadPart(bucket, object, uploadID, p.MD5Sum, p.Num, p.Len, p.ReadSeeker)
|
||||
completedPart, err := a.uploadPart(bucket, object, uploadID, p.MD5Sum, p.Num, p.Len, p.Reader)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
@@ -637,6 +646,21 @@ func (a api) PutObject(bucket, object, contentType string, size int64, data io.R
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// Special handling just for Google Cloud Storage.
|
||||
// TODO - we should remove this in future when we fully implement Resumable object upload.
|
||||
if a.config.Region == "google" {
|
||||
if size > maxPartSize {
|
||||
return ErrorResponse{
|
||||
Code: "EntityTooLarge",
|
||||
Message: "Your proposed upload exceeds the maximum allowed object size.",
|
||||
Resource: separator + bucket + separator + object,
|
||||
}
|
||||
}
|
||||
if _, err := a.putObject(bucket, object, contentType, nil, size, data); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
switch {
|
||||
case size < minimumPartSize && size > 0:
|
||||
// Single Part use case, use PutObject directly
|
||||
@@ -648,11 +672,11 @@ func (a api) PutObject(bucket, object, contentType string, size int64, data io.R
|
||||
if part.Len != size {
|
||||
return ErrorResponse{
|
||||
Code: "MethodUnexpectedEOF",
|
||||
Message: "Data read is less than the requested size",
|
||||
Message: "Data read is less than the requested size.",
|
||||
Resource: separator + bucket + separator + object,
|
||||
}
|
||||
}
|
||||
_, err := a.putObject(bucket, object, contentType, part.MD5Sum, part.Len, part.ReadSeeker)
|
||||
_, err := a.putObject(bucket, object, contentType, part.MD5Sum, part.Len, part.Reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -676,7 +700,7 @@ func (a api) PutObject(bucket, object, contentType string, size int64, data io.R
|
||||
}
|
||||
return a.continueObjectUpload(bucket, object, inProgressUploadID, size, data)
|
||||
}
|
||||
return errors.New("Unexpected control flow, please report this error at https://github.com/minio/minio-go-legacy/issues")
|
||||
return errors.New("Unexpected control flow, please report this error at https://github.com/minio/minio-go-legacy/issues.")
|
||||
}
|
||||
|
||||
// StatObject verify if object exists and you have permission to access it
|
||||
@@ -774,6 +798,33 @@ func (a api) GetBucketACL(bucket string) (BucketACL, error) {
|
||||
return "", err
|
||||
}
|
||||
grants := policy.AccessControlList.Grant
|
||||
// While it is compatible Google Cloud Storage behaves differently in terms of its XML reply.
|
||||
if a.config.Region == "google" {
|
||||
if len(grants) == 0 {
|
||||
return BucketACL("private"), nil
|
||||
}
|
||||
switch {
|
||||
case len(grants) == 1:
|
||||
if grants[0].Grantee.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" && grants[0].Permission == "READ" {
|
||||
return BucketACL("authenticated-read"), nil
|
||||
}
|
||||
if grants[0].Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && grants[0].Permission == "READ" {
|
||||
return BucketACL("public-read"), nil
|
||||
}
|
||||
case len(grants) == 2:
|
||||
for _, g := range grants {
|
||||
if g.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers" && g.Permission == "WRITE" {
|
||||
return BucketACL("public-read-write"), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return "", ErrorResponse{
|
||||
Code: "NoSuchBucketPolicy",
|
||||
Message: "The specified bucket does not have a bucket policy.",
|
||||
Resource: "/" + bucket,
|
||||
RequestID: "minio",
|
||||
}
|
||||
}
|
||||
switch {
|
||||
case len(grants) == 1:
|
||||
if grants[0].Grantee.URI == "" && grants[0].Permission == "FULL_CONTROL" {
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ func TestBucketOperations(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("Error")
|
||||
}
|
||||
if err.Error() != "Access Denied" {
|
||||
if err.Error() != "Access Denied." {
|
||||
t.Fatal("Error")
|
||||
}
|
||||
|
||||
|
||||
+27
-27
@@ -24,11 +24,11 @@ import (
|
||||
|
||||
// part - message structure for results from the MultiPart
|
||||
type part struct {
|
||||
MD5Sum []byte
|
||||
ReadSeeker io.ReadSeeker
|
||||
Err error
|
||||
Len int64
|
||||
Num int // part number
|
||||
MD5Sum []byte
|
||||
Reader io.Reader
|
||||
Err error
|
||||
Len int64
|
||||
Num int // part number
|
||||
}
|
||||
|
||||
// skipPart - skipping uploaded parts
|
||||
@@ -38,7 +38,7 @@ type skipPart struct {
|
||||
}
|
||||
|
||||
// chopper reads from io.Reader, partitions the data into chunks of given chunksize, and sends
|
||||
// each chunk as io.ReadSeeker to the caller over a channel
|
||||
// each chunk as io.Reader to the caller over a channel
|
||||
//
|
||||
// This method runs until an EOF or error occurs. If an error occurs,
|
||||
// the method sends the error over the channel and returns.
|
||||
@@ -58,20 +58,20 @@ func chopperInRoutine(reader io.Reader, chunkSize int64, skipParts []skipPart, c
|
||||
if err == io.EOF || err == io.ErrUnexpectedEOF { // short read, only single part return
|
||||
m := md5.Sum(p[0:n])
|
||||
ch <- part{
|
||||
MD5Sum: m[:],
|
||||
ReadSeeker: bytes.NewReader(p[0:n]),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: 1,
|
||||
MD5Sum: m[:],
|
||||
Reader: bytes.NewReader(p[0:n]),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: 1,
|
||||
}
|
||||
return
|
||||
}
|
||||
// catastrophic error send error and return
|
||||
if err != nil {
|
||||
ch <- part{
|
||||
ReadSeeker: nil,
|
||||
Err: err,
|
||||
Num: 0,
|
||||
Reader: nil,
|
||||
Err: err,
|
||||
Num: 0,
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -84,11 +84,11 @@ func chopperInRoutine(reader io.Reader, chunkSize int64, skipParts []skipPart, c
|
||||
}
|
||||
if !isPartNumberUploaded(sp, skipParts) {
|
||||
ch <- part{
|
||||
MD5Sum: md5SumBytes[:],
|
||||
ReadSeeker: bytes.NewReader(p),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: num,
|
||||
MD5Sum: md5SumBytes[:],
|
||||
Reader: bytes.NewReader(p),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: num,
|
||||
}
|
||||
}
|
||||
for err == nil {
|
||||
@@ -98,9 +98,9 @@ func chopperInRoutine(reader io.Reader, chunkSize int64, skipParts []skipPart, c
|
||||
if err != nil {
|
||||
if err != io.EOF && err != io.ErrUnexpectedEOF { // catastrophic error
|
||||
ch <- part{
|
||||
ReadSeeker: nil,
|
||||
Err: err,
|
||||
Num: 0,
|
||||
Reader: nil,
|
||||
Err: err,
|
||||
Num: 0,
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -115,11 +115,11 @@ func chopperInRoutine(reader io.Reader, chunkSize int64, skipParts []skipPart, c
|
||||
continue
|
||||
}
|
||||
ch <- part{
|
||||
MD5Sum: md5SumBytes[:],
|
||||
ReadSeeker: bytes.NewReader(p[0:n]),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: num,
|
||||
MD5Sum: md5SumBytes[:],
|
||||
Reader: bytes.NewReader(p[0:n]),
|
||||
Err: nil,
|
||||
Len: int64(n),
|
||||
Num: num,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ func invalidObjectError(object string) error {
|
||||
func invalidArgumentError(arg string) error {
|
||||
errorResponse := ErrorResponse{
|
||||
Code: "InvalidArgument",
|
||||
Message: "Invalid Argument",
|
||||
Message: "Invalid Argument.",
|
||||
RequestID: "minio",
|
||||
}
|
||||
if strings.TrimSpace(arg) == "" || arg == "" {
|
||||
|
||||
+13
-13
@@ -47,7 +47,7 @@ type operation struct {
|
||||
type request struct {
|
||||
req *http.Request
|
||||
config *Config
|
||||
body io.ReadSeeker
|
||||
body io.Reader
|
||||
expires int64
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ func newUnauthenticatedRequest(op *operation, config *Config, body io.Reader) (*
|
||||
}
|
||||
|
||||
// newRequest - instantiate a new request
|
||||
func newRequest(op *operation, config *Config, body io.ReadSeeker) (*request, error) {
|
||||
func newRequest(op *operation, config *Config, body io.Reader) (*request, error) {
|
||||
// if no method default to POST
|
||||
method := op.HTTPMethod
|
||||
if method == "" {
|
||||
@@ -356,14 +356,14 @@ func (r *request) PostPresignSignature(policyBase64 string) string {
|
||||
// Content-MD5 + "\n" +
|
||||
// Content-Type + "\n" +
|
||||
// Date + "\n" +
|
||||
// CanonicalizedAmzHeaders +
|
||||
// CanonicalizedProtocolHeaders +
|
||||
// CanonicalizedResource;
|
||||
//
|
||||
// CanonicalizedResource = [ "/" + Bucket ] +
|
||||
// <HTTP-Request-URI, from the protocol name up to the query string> +
|
||||
// [ subresource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
|
||||
//
|
||||
// CanonicalizedAmzHeaders = <described below>
|
||||
// CanonicalizedProtocolHeaders = <described below>
|
||||
|
||||
// SignV2 the request before Do() (version 2.0)
|
||||
func (r *request) SignV2() {
|
||||
@@ -392,14 +392,14 @@ func (r *request) SignV2() {
|
||||
// Content-MD5 + "\n" +
|
||||
// Content-Type + "\n" +
|
||||
// Date + "\n" +
|
||||
// CanonicalizedAmzHeaders +
|
||||
// CanonicalizedProtocolHeaders +
|
||||
// CanonicalizedResource;
|
||||
func (r *request) getStringToSign() string {
|
||||
buf := new(bytes.Buffer)
|
||||
// write standard headers
|
||||
r.writeDefaultHeaders(buf)
|
||||
// write canonicalized AMZ headers if any
|
||||
r.writeCanonicalizedAmzHeaders(buf)
|
||||
// write canonicalized protocol headers if any
|
||||
r.writeCanonicalizedHeaders(buf)
|
||||
// write canonicalized Query resources if any
|
||||
r.writeCanonicalizedResource(buf)
|
||||
return buf.String()
|
||||
@@ -416,19 +416,19 @@ func (r *request) writeDefaultHeaders(buf *bytes.Buffer) {
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
|
||||
func (r *request) writeCanonicalizedAmzHeaders(buf *bytes.Buffer) {
|
||||
var amzHeaders []string
|
||||
func (r *request) writeCanonicalizedHeaders(buf *bytes.Buffer) {
|
||||
var protoHeaders []string
|
||||
vals := make(map[string][]string)
|
||||
for k, vv := range r.req.Header {
|
||||
// all the AMZ headers go lower
|
||||
// all the AMZ and GOOG headers should be lowercase
|
||||
lk := strings.ToLower(k)
|
||||
if strings.HasPrefix(lk, "x-amz") {
|
||||
amzHeaders = append(amzHeaders, lk)
|
||||
protoHeaders = append(protoHeaders, lk)
|
||||
vals[lk] = vv
|
||||
}
|
||||
}
|
||||
sort.Strings(amzHeaders)
|
||||
for _, k := range amzHeaders {
|
||||
sort.Strings(protoHeaders)
|
||||
for _, k := range protoHeaders {
|
||||
buf.WriteString(k)
|
||||
buf.WriteByte(':')
|
||||
for idx, v := range vals[k] {
|
||||
|
||||
Vendored
+2
-2
@@ -34,8 +34,8 @@
|
||||
},
|
||||
{
|
||||
"path": "github.com/minio/minio-go-legacy",
|
||||
"revision": "8821642facdf11fd15092569dc27968033111dc0",
|
||||
"revisionTime": "2015-10-21T22:20:24-07:00"
|
||||
"revision": "16311b1e6475a05fea50b4c2051242b71600465c",
|
||||
"revisionTime": "2015-10-23T20:32:52-07:00"
|
||||
},
|
||||
{
|
||||
"path": "github.com/minio/minio-xl/pkg/probe",
|
||||
|
||||
Reference in New Issue
Block a user