aboutsummaryrefslogtreecommitdiff
path: root/weed/util
diff options
context:
space:
mode:
Diffstat (limited to 'weed/util')
-rw-r--r--weed/util/constants.go2
-rw-r--r--weed/util/http_util.go17
-rw-r--r--weed/util/retry.go10
3 files changed, 11 insertions, 18 deletions
diff --git a/weed/util/constants.go b/weed/util/constants.go
index f1864cf95..0aeee111e 100644
--- a/weed/util/constants.go
+++ b/weed/util/constants.go
@@ -5,7 +5,7 @@ import (
)
var (
- VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 10)
+ VERSION = fmt.Sprintf("%s %d.%02d", sizeLimit, 2, 11)
COMMIT = ""
)
diff --git a/weed/util/http_util.go b/weed/util/http_util.go
index 48823c1c3..7851d8293 100644
--- a/weed/util/http_util.go
+++ b/weed/util/http_util.go
@@ -1,7 +1,6 @@
package util
import (
- "bytes"
"compress/gzip"
"encoding/json"
"errors"
@@ -29,22 +28,6 @@ func init() {
}
}
-func PostBytes(url string, body []byte) ([]byte, error) {
- r, err := client.Post(url, "", bytes.NewReader(body))
- if err != nil {
- return nil, fmt.Errorf("Post to %s: %v", url, err)
- }
- defer r.Body.Close()
- b, err := ioutil.ReadAll(r.Body)
- if err != nil {
- return nil, fmt.Errorf("Read response body: %v", err)
- }
- if r.StatusCode >= 400 {
- return nil, fmt.Errorf("%s: %s", url, r.Status)
- }
- return b, nil
-}
-
func Post(url string, values url.Values) ([]byte, error) {
r, err := client.PostForm(url, values)
if err != nil {
diff --git a/weed/util/retry.go b/weed/util/retry.go
index faaab0351..85c4d150d 100644
--- a/weed/util/retry.go
+++ b/weed/util/retry.go
@@ -29,3 +29,13 @@ func Retry(name string, job func() error) (err error) {
}
return err
}
+
+// return the first non empty string
+func Nvl(values ...string) string {
+ for _, s := range values {
+ if s != "" {
+ return s
+ }
+ }
+ return ""
+}