If no body is supplied, don't send 'null' as body

This commit is contained in:
Paul Bonser 2017-02-02 15:08:39 -06:00
parent b04496cc3e
commit 63b210957a

View File

@ -82,7 +82,7 @@ func (req *Request) Request() (*http.Request, error) {
postData = req.Body
} else if req.API == "_bulk" {
postData = req.BulkData
} else {
} else if req.Body != nil {
b, err := json.Marshal(req.Query)
if err != nil {
return nil, err
@ -90,14 +90,12 @@ func (req *Request) Request() (*http.Request, error) {
postData = b
}
reader := ioutil.NopCloser(bytes.NewReader(postData))
newReq, err := http.NewRequest(req.Method, "", nil)
if err != nil {
return nil, err
}
newReq.URL = req.URL()
newReq.Body = reader
newReq.Body = ioutil.NopCloser(bytes.NewReader(postData))
newReq.ContentLength = int64(len(postData))
if req.Method == "POST" || req.Method == "PUT" {