1.gofmt httplib.go httplib_test.go

2.replace test url to http://httpbin.org functions
This commit is contained in:
CurveSoft
2014-06-04 21:04:50 +08:00
parent ebb3b91df9
commit bd537554ea
3 changed files with 38 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
// Beego (http://localhost/httplib_test.php)
// Beego (http://beego.me)
// @description beego is an open-source, high-performance web framework for the Go programming language.
// @link http://github.com/astaxie/beego for the canonical source repository
// @license http://github.com/astaxie/beego/blob/master/LICENSE
@@ -7,13 +7,13 @@
package httplib
import (
"testing"
"fmt"
"io/ioutil"
"testing"
)
func TestGetUrl(t *testing.T) {
resp, err := Get("http://localhost/httplib_test.php").Debug(true).Response()
resp, err := Get("http://beego.me").Debug(true).Response()
if err != nil {
t.Fatal(err)
}
@@ -29,7 +29,7 @@ func TestGetUrl(t *testing.T) {
t.Fatal("data is no")
}
str, err := Get("http://localhost/httplib_test.php").String()
str, err := Get("http://beego.me").String()
if err != nil {
t.Fatal(err)
}
@@ -39,7 +39,7 @@ func TestGetUrl(t *testing.T) {
}
func TestPost(t *testing.T) {
b := Post("http://localhost/httplib_test.php").Debug(true)
b := Post("http://beego.me").Debug(true)
b.Param("username", "astaxie")
b.Param("password", "hello")
b.PostFile("uploadfile", "httplib_test.php")
@@ -52,7 +52,7 @@ func TestPost(t *testing.T) {
func TestSimpleGetString(t *testing.T) {
fmt.Println("TestSimpleGetString==========================================")
html, err := Get("http://localhost/httplib_test.php").SetAgent("beegoooooo").String()
html, err := Get("http://httpbin.org/headers").SetAgent("beegoooooo").String()
if err != nil {
t.Fatal(err)
}
@@ -62,12 +62,12 @@ func TestSimpleGetString(t *testing.T) {
func TestSimpleGetStringWithDefaultCookie(t *testing.T) {
fmt.Println("TestSimpleGetStringWithDefaultCookie==========================================")
html, err := Get("http://localhost/httplib_test.php").SetEnableCookie(true).String()
html, err := Get("http://httpbin.org/cookies/set?k1=v1").SetEnableCookie(true).String()
if err != nil {
t.Fatal(err)
}
fmt.Println(html)
html, err = Get("http://localhost/httplib_test.php").SetEnableCookie(true).String()
html, err = Get("http://httpbin.org/cookies").SetEnableCookie(true).String()
if err != nil {
t.Fatal(err)
}
@@ -83,15 +83,15 @@ func TestDefaultSetting(t *testing.T) {
def.UserAgent = "UserAgent"
//def.ConnectTimeout = 60*time.Second
//def.ReadWriteTimeout = 60*time.Second
def.Transport = nil//http.DefaultTransport
def.Transport = nil //http.DefaultTransport
SetDefaultSetting(def)
html, err := Get("http://localhost/httplib_test.php").String()
html, err := Get("http://httpbin.org/headers").String()
if err != nil {
t.Fatal(err)
}
fmt.Println(html)
html, err = Get("http://localhost/httplib_test.php").String()
html, err = Get("http://httpbin.org/headers").String()
if err != nil {
t.Fatal(err)
}