diff --git a/vendor/github.com/minio/minio-go/api-list.go b/vendor/github.com/minio/minio-go/api-list.go index 534ac4eb..c7cbac7d 100644 --- a/vendor/github.com/minio/minio-go/api-list.go +++ b/vendor/github.com/minio/minio-go/api-list.go @@ -188,11 +188,11 @@ func (c Client) listObjectsQuery(bucketName, objectPrefix, objectMarker, delimit urlValues := make(url.Values) // Set object prefix. if objectPrefix != "" { - urlValues.Set("prefix", urlEncodePath(objectPrefix)) + urlValues.Set("prefix", objectPrefix) } // Set object marker. if objectMarker != "" { - urlValues.Set("marker", urlEncodePath(objectMarker)) + urlValues.Set("marker", objectMarker) } // Set delimiter. if delimiter != "" { @@ -366,7 +366,7 @@ func (c Client) listMultipartUploadsQuery(bucketName, keyMarker, uploadIDMarker, urlValues.Set("uploads", "") // Set object key marker. if keyMarker != "" { - urlValues.Set("key-marker", urlEncodePath(keyMarker)) + urlValues.Set("key-marker", keyMarker) } // Set upload id marker. if uploadIDMarker != "" { @@ -374,7 +374,7 @@ func (c Client) listMultipartUploadsQuery(bucketName, keyMarker, uploadIDMarker, } // Set prefix marker. if prefix != "" { - urlValues.Set("prefix", urlEncodePath(prefix)) + urlValues.Set("prefix", prefix) } // Set delimiter. if delimiter != "" { diff --git a/vendor/github.com/minio/minio-go/api-put-object-common.go b/vendor/github.com/minio/minio-go/api-put-object-common.go index beab6d6c..1584497b 100644 --- a/vendor/github.com/minio/minio-go/api-put-object-common.go +++ b/vendor/github.com/minio/minio-go/api-put-object-common.go @@ -94,6 +94,58 @@ func optimalPartInfo(objectSize int64) (totalPartsCount int, partSize int64, las return totalPartsCount, partSize, lastPartSize, nil } +// Compatibility code for Golang < 1.5.x. +// copyBuffer is identical to io.CopyBuffer, since such a function is +// not available/implemented in Golang version < 1.5.x, we use a +// custom call exactly implementng io.CopyBuffer from Golang > 1.5.x +// version does. +// +// copyBuffer stages through the provided buffer (if one is required) +// rather than allocating a temporary one. If buf is nil, one is +// allocated; otherwise if it has zero length, copyBuffer panics. +// +// FIXME: Remove this code when distributions move to newer Golang versions. +func copyBuffer(writer io.Writer, reader io.Reader, buf []byte) (written int64, err error) { + // If the reader has a WriteTo method, use it to do the copy. + // Avoids an allocation and a copy. + if wt, ok := reader.(io.WriterTo); ok { + return wt.WriteTo(writer) + } + // Similarly, if the writer has a ReadFrom method, use it to do + // the copy. + if rt, ok := writer.(io.ReaderFrom); ok { + return rt.ReadFrom(reader) + } + if buf == nil { + buf = make([]byte, 32*1024) + } + for { + nr, er := reader.Read(buf) + if nr > 0 { + nw, ew := writer.Write(buf[0:nr]) + if nw > 0 { + written += int64(nw) + } + if ew != nil { + err = ew + break + } + if nr != nw { + err = io.ErrShortWrite + break + } + } + if er == io.EOF { + break + } + if er != nil { + err = er + break + } + } + return written, err +} + // hashCopyBuffer is identical to hashCopyN except that it stages // through the provided buffer (if one is required) rather than // allocating a temporary one. If buf is nil, one is allocated for 5MiB. @@ -113,9 +165,9 @@ func (c Client) hashCopyBuffer(writer io.Writer, reader io.Reader, buf []byte) ( buf = make([]byte, optimalReadBufferSize) } - // Using io.CopyBuffer to copy in large buffers, default buffer + // Using copyBuffer to copy in large buffers, default buffer // for io.Copy of 32KiB is too small. - size, err = io.CopyBuffer(hashWriter, reader, buf) + size, err = copyBuffer(hashWriter, reader, buf) if err != nil { return nil, nil, 0, err } @@ -215,7 +267,7 @@ func (c Client) computeHashBuffer(reader io.ReadSeeker, buf []byte) (md5Sum, sha return nil, nil, 0, err } } else { - size, err = io.CopyBuffer(hashWriter, reader, buf) + size, err = copyBuffer(hashWriter, reader, buf) if err != nil { return nil, nil, 0, err } diff --git a/vendor/github.com/minio/minio-go/api.go b/vendor/github.com/minio/minio-go/api.go index 96cab8c0..f4d2f52f 100644 --- a/vendor/github.com/minio/minio-go/api.go +++ b/vendor/github.com/minio/minio-go/api.go @@ -478,7 +478,7 @@ func (c Client) makeTargetURL(bucketName, objectName, bucketLocation string, que } // If there are any query values, add them to the end. if len(queryValues) > 0 { - urlStr = urlStr + "?" + queryValues.Encode() + urlStr = urlStr + "?" + queryEncode(queryValues) } u, err := url.Parse(urlStr) if err != nil { diff --git a/vendor/github.com/minio/minio-go/api_unit_test.go b/vendor/github.com/minio/minio-go/api_unit_test.go index 2afc666d..cbae12fe 100644 --- a/vendor/github.com/minio/minio-go/api_unit_test.go +++ b/vendor/github.com/minio/minio-go/api_unit_test.go @@ -397,6 +397,22 @@ func TestPartSize(t *testing.T) { } } +// Tests query values to URL encoding. +func TestQueryURLEncoding(t *testing.T) { + urlValues := make(url.Values) + urlValues.Set("prefix", "test@1123") + urlValues.Set("delimiter", "/") + urlValues.Set("marker", "%%%@$$$") + + queryStr := queryEncode(urlValues) + if !strings.Contains(queryStr, "test%401123") { + t.Fatalf("Error: @ should be encoded as %s, invalid query string %s", "test%401123", queryStr) + } + if !strings.Contains(queryStr, "%25%25%25%40%24%24%24") { + t.Fatalf("Error: %s should be encoded as %s, invalid query string %s", "%%%@$$$", "%25%25%25%40%24%24%24", queryStr) + } +} + // Tests url encoding. func TestURLEncoding(t *testing.T) { type urlStrings struct { diff --git a/vendor/github.com/minio/minio-go/utils.go b/vendor/github.com/minio/minio-go/utils.go index 63966c30..1636e8e0 100644 --- a/vendor/github.com/minio/minio-go/utils.go +++ b/vendor/github.com/minio/minio-go/utils.go @@ -17,6 +17,7 @@ package minio import ( + "bytes" "crypto/hmac" "crypto/sha256" "encoding/hex" @@ -27,6 +28,7 @@ import ( "net/http" "net/url" "regexp" + "sort" "strings" "time" "unicode/utf8" @@ -183,7 +185,7 @@ func isValidEndpointURL(endpointURL *url.URL) error { return ErrInvalidArgument("Endpoint url cannot be empty.") } if endpointURL.Path != "/" && endpointURL.Path != "" { - return ErrInvalidArgument("Endpoing url cannot have fully qualified paths.") + return ErrInvalidArgument("Endpoint url cannot have fully qualified paths.") } if strings.Contains(endpointURL.Host, ".amazonaws.com") { if !isAmazonEndpoint(endpointURL) { @@ -264,6 +266,31 @@ func isValidObjectPrefix(objectPrefix string) error { return nil } +// queryEncode - encodes query values in their URL encoded form. +func queryEncode(v url.Values) string { + if v == nil { + return "" + } + var buf bytes.Buffer + keys := make([]string, 0, len(v)) + for k := range v { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + vs := v[k] + prefix := urlEncodePath(k) + "=" + for _, v := range vs { + if buf.Len() > 0 { + buf.WriteByte('&') + } + buf.WriteString(prefix) + buf.WriteString(urlEncodePath(v)) + } + } + return buf.String() +} + // urlEncodePath encode the strings from UTF-8 byte representations to HTML hex escape sequences // // This is necessary since regular url.Parse() and url.Encode() functions do not support UTF-8 diff --git a/vendor/vendor.json b/vendor/vendor.json index 518ecb07..f0b93ab1 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -29,8 +29,8 @@ }, { "path": "github.com/minio/minio-go", - "revision": "4d50c1ea5864a5740c5e5610f0547eb9a0d5b81f", - "revisionTime": "2016-01-27T14:26:51-08:00" + "revision": "c5884ce9ce3ac73b025d0bc58c4d3d72870edc0b", + "revisionTime": "2016-02-02T13:13:10+05:30" }, { "path": "github.com/minio/minio-xl/pkg/atomic",