From 02301caac165dbf3e2da175558550268bc1064e9 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Sat, 23 Aug 2014 06:47:42 +0800 Subject: [PATCH 1/4] modify desc --- httplib/httplib.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index 6531acd2..d289d9d4 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -101,7 +101,7 @@ func Put(url string) *BeegoHttpRequest { return newBeegoRequest(url, "PUT") } -// Delete returns *BeegoHttpRequest DELETE GET method. +// Delete returns *BeegoHttpRequest DELETE method. func Delete(url string) *BeegoHttpRequest { return newBeegoRequest(url, "DELETE") } From 7b2fe824d5189bf9ac22dbcb6539f83141f67039 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Sat, 23 Aug 2014 06:48:40 +0800 Subject: [PATCH 2/4] typo fixed --- httplib/httplib.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index d289d9d4..a1396e87 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -14,7 +14,7 @@ // Usage: // -// import "github.com/astaxie/beego/context" +// import "github.com/astaxie/beego/httplib" // // b := httplib.Post("http://beego.me/") // b.Param("username","astaxie") From d8f2b05e0861cf99ff24623268758c18cd40d885 Mon Sep 17 00:00:00 2001 From: JessonChan Date: Sat, 23 Aug 2014 07:02:47 +0800 Subject: [PATCH 3/4] improve the code and delete NO NEED URL CHECK --- httplib/httplib.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index a1396e87..b7220a60 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -75,14 +75,14 @@ func SetDefaultSetting(setting BeegoHttpSettings) { // return *BeegoHttpRequest with specific method func newBeegoRequest(url, method string) *BeegoHttpRequest { + var resp http.Response req := http.Request{ + Method: method, + Header: make(http.Header), Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, } - var resp http.Response - req.Method = method - req.Header = http.Header{} return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil} } @@ -310,10 +310,6 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { } url, err := url.Parse(b.url) - if url.Scheme == "" { - b.url = "http://" + b.url - url, err = url.Parse(b.url) - } if err != nil { return nil, err } From c07b1d881b38c28fac5d538f658ae91f0e43a2eb Mon Sep 17 00:00:00 2001 From: JessonChan Date: Sat, 23 Aug 2014 07:07:12 +0800 Subject: [PATCH 4/4] typo fixed --- httplib/httplib.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index b7220a60..b1f209c9 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -53,7 +53,7 @@ var defaultSetting = BeegoHttpSettings{false, "beegoServer", 60 * time.Second, 6 var defaultCookieJar http.CookieJar var settingMutex sync.Mutex -// createDefaultCookieJar creates a global cookiejar to store cookies. +// createDefaultCookie creates a global cookiejar to store cookies. func createDefaultCookie() { settingMutex.Lock() defer settingMutex.Unlock()