1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 21:11:29 +00:00

Merge pull request #322 from pengfei-xue/devel

there is no need to check if b.params is nil
This commit is contained in:
astaxie 2013-11-27 23:05:05 -08:00
commit 0ba36763f5

View File

@ -103,7 +103,7 @@ func (b *BeegoHttpRequest) Body(data interface{}) *BeegoHttpRequest {
func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
var paramBody string var paramBody string
if b.params != nil && len(b.params) > 0 { if len(b.params) > 0 {
var buf bytes.Buffer var buf bytes.Buffer
for k, v := range b.params { for k, v := range b.params {
buf.WriteString(url.QueryEscape(k)) buf.WriteString(url.QueryEscape(k))
@ -114,6 +114,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
paramBody = buf.String() paramBody = buf.String()
paramBody = paramBody[0 : len(paramBody)-1] paramBody = paramBody[0 : len(paramBody)-1]
} }
if b.req.Method == "GET" && len(paramBody) > 0 { if b.req.Method == "GET" && len(paramBody) > 0 {
if strings.Index(b.url, "?") != -1 { if strings.Index(b.url, "?") != -1 {
b.url += "&" + paramBody b.url += "&" + paramBody
@ -130,10 +131,10 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) {
b.url = "http://" + b.url b.url = "http://" + b.url
url, err = url.Parse(b.url) url, err = url.Parse(b.url)
} }
if err != nil { if err != nil {
return nil, err return nil, err
} }
b.req.URL = url b.req.URL = url
if b.showdebug { if b.showdebug {
dump, err := httputil.DumpRequest(b.req, true) dump, err := httputil.DumpRequest(b.req, true)