1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-28 02:04:13 +00:00

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

7
.idea/go_settings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GoProjectSettings">
<option name="enableOptimizeImports" value="true" />
</component>
</project>

View File

@ -16,13 +16,13 @@ import (
"mime/multipart"
"net"
"net/http"
"net/http/httputil"
"net/http/cookiejar"
"net/http/httputil"
"net/url"
"os"
"strings"
"time"
"sync"
"time"
)
var defaultSetting = BeegoHttpSettings{false, "beegoServer", 60 * time.Second, 60 * time.Second, nil, nil, nil, false}

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)
}
@ -86,12 +86,12 @@ func TestDefaultSetting(t *testing.T) {
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)
}