diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-04-21 02:11:10 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-04-21 02:11:10 -0700 |
| commit | 1818a2a2da412710f57d58f0228009f782b760af (patch) | |
| tree | e51f2e816dabcc7ac1ea42118bc9c74469367910 /go/util | |
| parent | 637469e656c09d6e8d682e90ed0497f64e892f29 (diff) | |
| download | seaweedfs-1818a2a2da412710f57d58f0228009f782b760af.tar.xz seaweedfs-1818a2a2da412710f57d58f0228009f782b760af.zip | |
Change to protocol buffer for volume-join-masster message
Reduced size to about 1/5 of the previous json format message
Diffstat (limited to 'go/util')
| -rw-r--r-- | go/util/http_util.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/go/util/http_util.go b/go/util/http_util.go index a33db9199..6562e964c 100644 --- a/go/util/http_util.go +++ b/go/util/http_util.go @@ -1,6 +1,7 @@ package util import ( + "bytes" "code.google.com/p/weed-fs/go/glog" "fmt" "io/ioutil" @@ -21,6 +22,21 @@ func init() { client = &http.Client{Transport: Transport} } +func PostBytes(url string, body []byte) ([]byte, error) { + r, err := client.Post(url, "application/octet-stream", bytes.NewReader(body)) + if err != nil { + glog.V(0).Infoln(err) + return nil, err + } + defer r.Body.Close() + b, err := ioutil.ReadAll(r.Body) + if err != nil { + glog.V(0).Infoln("read post result from", url, err) + return nil, err + } + return b, nil +} + func Post(url string, values url.Values) ([]byte, error) { r, err := client.PostForm(url, values) if err != nil { |
