move httplib from beego to beego/httplib safemap support get all items

This commit is contained in:
astaxie
2013-08-06 16:13:45 +08:00
parent 64ef8ad62b
commit 4ecb9cc30b
3 changed files with 8 additions and 2 deletions

32
httplib/httplib_test.go Normal file
View File

@@ -0,0 +1,32 @@
package httplib
import (
"io/ioutil"
"testing"
)
func TestGetUrl(t *testing.T) {
resp, err := Get("http://beego.me/").Response()
if err != nil {
t.Fatal(err)
}
if resp.Body == nil {
t.Fatal("body is nil")
}
data, err := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
t.Fatal(err)
}
if len(data) == 0 {
t.Fatal("data is no")
}
str, err := Get("http://beego.me/").String()
if err != nil {
t.Fatal(err)
}
if len(str) == 0 {
t.Fatal("has no info")
}
}