You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
439 B

  1. package util
  2. import (
  3. "code.google.com/p/weed-fs/go/glog"
  4. "io/ioutil"
  5. "net/http"
  6. "net/url"
  7. )
  8. func Post(url string, values url.Values) ([]byte, error) {
  9. r, err := http.PostForm(url, values)
  10. if err != nil {
  11. glog.V(0).Infoln("post to", url, err)
  12. return nil, err
  13. }
  14. defer r.Body.Close()
  15. b, err := ioutil.ReadAll(r.Body)
  16. if err != nil {
  17. glog.V(0).Infoln("read post result from", url, err)
  18. return nil, err
  19. }
  20. return b, nil
  21. }