diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index 7dc32ac1..6010d026 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -36,7 +36,7 @@
},
{
"ImportPath": "github.com/minio/objectstorage-go",
- "Rev": "0b5d5f294de9f3871ae9cc23bb9753175da8f2dd"
+ "Rev": "883ebdb4593b397713be5f0818174f71ee6724e0"
},
{
"ImportPath": "github.com/shiena/ansicolor",
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/.travis.yml b/Godeps/_workspace/src/github.com/minio/objectstorage-go/.travis.yml
index 34aeb1d5..52273843 100644
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/.travis.yml
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/.travis.yml
@@ -1,6 +1,6 @@
language: go
go:
- 1.4.2
-sudo: false
-notifications:
- slack: travisci:0lsU2EbtMOizjtgSmBZUNEQS
\ No newline at end of file
+script:
+- go vet ./...
+- go test -race -v ./...
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go
index 3cef328c..5b3b5adb 100644
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api.go
@@ -20,6 +20,7 @@ import (
"errors"
"io"
"net/http"
+ "runtime"
"sort"
"strings"
"time"
@@ -156,16 +157,17 @@ func (c *Config) MustGetEndpoint() string {
// fall back to custom Endpoint, if no valid region can be found
return c.Endpoint
}
- // if not endpoint or region sepcified default to us-east-1
+ // if not endpoint or region specified default to us-east-1
c.Region = "us-east-1"
return getEndpoint(c.Region)
}
// AddUserAgent - append to a default user agent
func (c *Config) AddUserAgent(name string, version string, comments ...string) {
+ c.userAgent = LibraryName + "/" + LibraryVersion + " (" + runtime.GOOS + ", " + runtime.GOARCH + ") "
+ // if no name and version is set we do not add new user agents
if name != "" && version != "" {
- newUserAgent := name + "/" + version + " (" + strings.Join(comments, ", ") + ") "
- c.userAgent = c.userAgent + " " + newUserAgent
+ c.userAgent = c.userAgent + " " + name + "/" + version + " (" + strings.Join(comments, ", ") + ") "
}
}
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_objecthandlers_test.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_objecthandlers_test.go
new file mode 100644
index 00000000..eaddb584
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_objecthandlers_test.go
@@ -0,0 +1,131 @@
+/*
+ * Minimal object storage library (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package objectstorage
+
+// bucketHandler is an http.Handler that verifies bucket responses and validates incoming requests
+import (
+ "bytes"
+ "io"
+ "net/http"
+ "strconv"
+ "time"
+)
+
+type bucketHandler struct {
+ resource string
+}
+
+func (h bucketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == "GET":
+ switch {
+ case r.URL.Path == "/":
+ response := []byte("bucket2015-05-20T23:05:09.230Zminiominio")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ case r.URL.Path == "/bucket":
+ response := []byte("259d04a13802ae09c7e41be50ccc6baaobject2015-05-21T18:24:21.097Z22061miniominioSTANDARDfalse1000testbucket")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ }
+ case r.Method == "PUT":
+ switch {
+ case r.URL.Path == h.resource:
+ _, ok := r.URL.Query()["acl"]
+ if ok {
+ if r.Header.Get("x-amz-acl") != "public-read-write" {
+ w.WriteHeader(http.StatusNotImplemented)
+ }
+ }
+ w.WriteHeader(http.StatusOK)
+ default:
+ w.WriteHeader(http.StatusBadRequest)
+ }
+ case r.Method == "HEAD":
+ switch {
+ case r.URL.Path == h.resource:
+ w.WriteHeader(http.StatusOK)
+ default:
+ w.WriteHeader(http.StatusForbidden)
+ }
+ case r.Method == "DELETE":
+ switch {
+ case r.URL.Path != h.resource:
+ w.WriteHeader(http.StatusNotFound)
+ default:
+ h.resource = ""
+ w.WriteHeader(http.StatusOK)
+ }
+ }
+}
+
+// objectHandler is an http.Handler that verifies object responses and validates incoming requests
+type objectHandler struct {
+ resource string
+ data []byte
+}
+
+func (h objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == "PUT":
+ length, err := strconv.Atoi(r.Header.Get("Content-Length"))
+ if err != nil {
+ w.WriteHeader(http.StatusBadRequest)
+ return
+ }
+ var buffer bytes.Buffer
+ _, err = io.CopyN(&buffer, r.Body, int64(length))
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ if !bytes.Equal(h.data, buffer.Bytes()) {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
+ w.WriteHeader(http.StatusOK)
+ case r.Method == "HEAD":
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
+ w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
+ w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
+ w.WriteHeader(http.StatusOK)
+ case r.Method == "POST":
+ case r.Method == "GET":
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
+ w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
+ w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
+ w.WriteHeader(http.StatusOK)
+ io.Copy(w, bytes.NewReader(h.data))
+ case r.Method == "DELETE":
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ h.resource = ""
+ h.data = nil
+ w.WriteHeader(http.StatusOK)
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_test.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_test.go
index e6a5ed61..6c741336 100644
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_test.go
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/api_test.go
@@ -20,11 +20,9 @@ import (
"bytes"
"fmt"
"io"
- "net/http"
"net/http/httptest"
- "strconv"
+ "strings"
"testing"
- "time"
)
func ExampleGetPartSize() {
@@ -36,52 +34,43 @@ func ExampleGetPartSize_second() {
// Output: 5368709120
}
-// bucketHandler is an http.Handler that verifies bucket responses and validates incoming requests
-type bucketHandler struct {
- resource string
+func TestMustGetEndpoint(t *testing.T) {
+ conf := new(Config)
+ conf.Region = "us-east-1"
+ if conf.MustGetEndpoint() != "https://s3.amazonaws.com" {
+ t.Fatalf("Error")
+ }
+
+ conf.Region = ""
+ conf.Endpoint = "http://localhost:9000"
+ if conf.MustGetEndpoint() != "http://localhost:9000" && conf.Region == "milkyway" {
+ t.Fatalf("Error")
+ }
+
+ conf.Region = ""
+ conf.Endpoint = "https://s3.amazonaws.com"
+ if conf.MustGetEndpoint() != "https://s3.amazonaws.com" && conf.Region == "us-east-1" {
+ t.Fatalf("Error")
+ }
+
+ conf.Region = "invalid"
+ conf.Endpoint = "http://play.minio.io:9000"
+ if conf.MustGetEndpoint() != "http://play.minio.io:9000" {
+ t.Fatalf("Error")
+ }
+
+ conf.Region = ""
+ conf.Endpoint = ""
+ if conf.MustGetEndpoint() != "https://s3.amazonaws.com" && conf.Region == "us-east-1" {
+ t.Fatalf("Error")
+ }
}
-func (h bucketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- switch {
- case r.Method == "GET":
- switch {
- case r.URL.Path == "/":
- response := []byte("bucket2015-05-20T23:05:09.230Zminiominio")
- w.Header().Set("Content-Length", strconv.Itoa(len(response)))
- w.Write(response)
- case r.URL.Path == "/bucket":
- response := []byte("259d04a13802ae09c7e41be50ccc6baaobject2015-05-21T18:24:21.097Z22061miniominioSTANDARDfalse1000testbucket")
- w.Header().Set("Content-Length", strconv.Itoa(len(response)))
- w.Write(response)
- }
- case r.Method == "PUT":
- switch {
- case r.URL.Path == h.resource:
- _, ok := r.URL.Query()["acl"]
- if ok {
- if r.Header.Get("x-amz-acl") != "public-read-write" {
- w.WriteHeader(http.StatusNotImplemented)
- }
- }
- w.WriteHeader(http.StatusOK)
- default:
- w.WriteHeader(http.StatusBadRequest)
- }
- case r.Method == "HEAD":
- switch {
- case r.URL.Path == h.resource:
- w.WriteHeader(http.StatusOK)
- default:
- w.WriteHeader(http.StatusForbidden)
- }
- case r.Method == "DELETE":
- switch {
- case r.URL.Path != h.resource:
- w.WriteHeader(http.StatusNotFound)
- default:
- h.resource = ""
- w.WriteHeader(http.StatusOK)
- }
+func TestUserAgent(t *testing.T) {
+ conf := new(Config)
+ conf.AddUserAgent("minio", "1.0", "amd64")
+ if !strings.Contains(conf.userAgent, "minio") {
+ t.Fatalf("Error")
}
}
@@ -148,63 +137,6 @@ func TestBucketOperations(t *testing.T) {
}
}
-// objectHandler is an http.Handler that verifies object responses and validates incoming requests
-type objectHandler struct {
- resource string
- data []byte
-}
-
-func (h objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- switch {
- case r.Method == "PUT":
- length, err := strconv.Atoi(r.Header.Get("Content-Length"))
- if err != nil {
- w.WriteHeader(http.StatusBadRequest)
- return
- }
- var buffer bytes.Buffer
- _, err = io.CopyN(&buffer, r.Body, int64(length))
- if err != nil {
- w.WriteHeader(http.StatusInternalServerError)
- return
- }
- if !bytes.Equal(h.data, buffer.Bytes()) {
- w.WriteHeader(http.StatusInternalServerError)
- return
- }
- w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
- w.WriteHeader(http.StatusOK)
- case r.Method == "HEAD":
- if r.URL.Path != h.resource {
- w.WriteHeader(http.StatusNotFound)
- return
- }
- w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
- w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
- w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
- w.WriteHeader(http.StatusOK)
- case r.Method == "POST":
- case r.Method == "GET":
- if r.URL.Path != h.resource {
- w.WriteHeader(http.StatusNotFound)
- return
- }
- w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
- w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
- w.Header().Set("ETag", "9af2f8218b150c351ad802c6f3d66abe")
- w.WriteHeader(http.StatusOK)
- io.Copy(w, bytes.NewReader(h.data))
- case r.Method == "DELETE":
- if r.URL.Path != h.resource {
- w.WriteHeader(http.StatusNotFound)
- return
- }
- h.resource = ""
- h.data = nil
- w.WriteHeader(http.StatusOK)
- }
-}
-
func TestObjectOperations(t *testing.T) {
object := objectHandler(objectHandler{
resource: "/bucket/object",
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_common.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_common.go
index 1f9a6a92..debd1b3b 100644
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_common.go
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_common.go
@@ -31,7 +31,7 @@ import (
// urlEncodedName- encode the strings from UTF-8 byte representations to HTML hex escape sequences
func urlEncodeName(objectName string) (string, error) {
// if object matches reserved string, no need to encode them
- reservedNames := regexp.MustCompile("^[a-zA-Z0-9-_.~/ ]+$")
+ reservedNames := regexp.MustCompile("^[a-zA-Z0-9-_.~/]+$")
if reservedNames.MatchString(objectName) {
return objectName, nil
}
@@ -42,7 +42,7 @@ func urlEncodeName(objectName string) (string, error) {
continue
}
switch s {
- case '-', '_', '.', '~', '/', ' ': // §2.3 Unreserved characters (mark)
+ case '-', '_', '.', '~', '/': // §2.3 Unreserved characters (mark)
encodedObjectName = encodedObjectName + string(s)
continue
default:
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_request.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_request.go
index c0caaf0e..dc72f524 100644
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_request.go
+++ b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_request.go
@@ -72,8 +72,12 @@ func newRequest(op *operation, config *Config, body io.ReadSeeker) (*request, er
return nil, err
}
+ // if userAgent empty do not set it
+ if config.userAgent != "" {
+ config.userAgent = LibraryName + "/" + LibraryVersion + " (" + runtime.GOOS + ", " + runtime.GOARCH + ") "
+ }
+
// set UserAgent
- config.userAgent = config.userAgent + LibraryName + "/" + LibraryVersion + " (" + runtime.GOOS + ", " + runtime.GOARCH + ") "
req.Header.Set("User-Agent", config.userAgent)
// set Accept header for response encoding style, if available
@@ -206,6 +210,8 @@ func (r *request) getSignedHeaders() string {
func (r *request) getCanonicalRequest(hashedPayload string) string {
r.req.URL.RawQuery = strings.Replace(r.req.URL.Query().Encode(), "+", "%20", -1)
encodedPath, _ := urlEncodeName(r.req.URL.Path)
+ // convert any space strings back to "+"
+ encodedPath = strings.Replace(encodedPath, "+", "%20", -1)
canonicalRequest := strings.Join([]string{
r.req.Method,
encodedPath,
diff --git a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_test.go b/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_test.go
deleted file mode 100644
index 20dbcf06..00000000
--- a/Godeps/_workspace/src/github.com/minio/objectstorage-go/low_level_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Minimal object storage library (C) 2015 Minio, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package objectstorage_test
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "testing"
-)
-
-var robotsTxtHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Last-Modified", "sometime")
- fmt.Fprintf(w, "User-agent: go\nDisallow: /something/")
-})
-
-func TestNewRequest(t *testing.T) {
-}
-
-func TestResponseToError(t *testing.T) {
-}
-
-func TestCommonFunctions(t *testing.T) {
-}
-
-func TestLowLevelBucketOperations(t *testing.T) {
- ts := httptest.NewServer(robotsTxtHandler)
- defer ts.Close()
-}
-
-func TestLowLevelObjectOperations(t *testing.T) {
- ts := httptest.NewServer(robotsTxtHandler)
- defer ts.Close()
-}
-
-func TestLowLevelMultiPartOperations(t *testing.T) {
- ts := httptest.NewServer(robotsTxtHandler)
- defer ts.Close()
-}