seaweedfs/go/util/post.go
2013-02-10 03:49:51 -08:00

24 lines
399 B
Go

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 {
log.Println("post to", url, err)
return nil, err
}
defer r.Body.Close()
b, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Println("read post result from", url, err)
return nil, err
}
return b, nil
}