seaweedfs/go/util/post.go

24 lines
399 B
Go
Raw Normal View History

package util
import (
"io/ioutil"
"log"
"net/http"
"net/url"
)
func Post(url string, values url.Values) ([]byte, error) {
r, err := http.PostForm(url, values)
if err != nil {
2012-09-26 08:55:56 +00:00
log.Println("post to", url, err)
return nil, err
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
2013-01-17 08:56:56 +00:00
log.Println("read post result from", url, err)
return nil, err
}
return b, nil
}