mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-14 21:16:17 +08:00
Change to protocol buffer for volume-join-masster message
Reduced size to about 1/5 of the previous json format message
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user