1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:30:54 +00:00

there is no need to check if b.params is nil

This commit is contained in:
Pengfei Xue 2013-11-28 13:52:24 +08:00
parent a83a92cdab
commit 3fce78c7cd

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)