From 824e3f8f5b1c788801ffcb3425ffd32059f9c682 Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 29 Oct 2014 16:00:04 +0800 Subject: [PATCH] fix the only file upload param --- httplib/httplib.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httplib/httplib.go b/httplib/httplib.go index dbcb2fed..bced9163 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -275,7 +275,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { } else { b.url = b.url + "?" + paramBody } - } else if b.req.Method == "POST" && b.req.Body == nil && len(paramBody) > 0 { + } else if b.req.Method == "POST" && b.req.Body == nil { if len(b.files) > 0 { bodyBuf := &bytes.Buffer{} bodyWriter := multipart.NewWriter(bodyBuf) @@ -303,7 +303,7 @@ func (b *BeegoHttpRequest) getResponse() (*http.Response, error) { b.Header("Content-Type", contentType) b.req.Body = ioutil.NopCloser(bodyBuf) b.req.ContentLength = int64(bodyBuf.Len()) - } else { + } else if len(paramBody) > 0 { b.Header("Content-Type", "application/x-www-form-urlencoded") b.Body(paramBody) }