0ba36763 by astaxie

Merge pull request #322 from pengfei-xue/devel

there is no need to check if b.params is nil
2 parents a83a92cd 3fce78c7
...@@ -103,7 +103,7 @@ func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest { ...@@ -103,7 +103,7 @@ func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest {
103 103
104 func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { 104 func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
105 var paramBody string 105 var paramBody string
106 if b.params != nil && len(b.params) > 0 { 106 if len(b.params) > 0 {
107 var buf bytes.Buffer 107 var buf bytes.Buffer
108 for k, v := range b.params { 108 for k, v := range b.params {
109 buf.WriteString(url.QueryEscape(k)) 109 buf.WriteString(url.QueryEscape(k))
...@@ -114,6 +114,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { ...@@ -114,6 +114,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
114 paramBody = buf.String() 114 paramBody = buf.String()
115 paramBody = paramBody[0 : len(paramBody)-1] 115 paramBody = paramBody[0 : len(paramBody)-1]
116 } 116 }
117
117 if b.req.Method == "GET" && len(paramBody) > 0 { 118 if b.req.Method == "GET" && len(paramBody) > 0 {
118 if strings.Index(b.url, "?") != -1 { 119 if strings.Index(b.url, "?") != -1 {
119 b.url += "&" + paramBody 120 b.url += "&" + paramBody
...@@ -130,10 +131,10 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { ...@@ -130,10 +131,10 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
130 b.url = "http://" + b.url 131 b.url = "http://" + b.url
131 url, err = url.Parse(b.url) 132 url, err = url.Parse(b.url)
132 } 133 }
133
134 if err != nil { 134 if err != nil {
135 return nil, err 135 return nil, err
136 } 136 }
137
137 b.req.URL = url 138 b.req.URL = url
138 if b.showdebug { 139 if b.showdebug {
139 dump, err := httputil.DumpRequest(b.req, true) 140 dump, err := httputil.DumpRequest(b.req, true)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!