If no body is supplied, don't send 'null' as body
This commit is contained in:
parent
b04496cc3e
commit
63b210957a
@ -82,7 +82,7 @@ func (req *Request) Request() (*http.Request, error) {
|
|||||||
postData = req.Body
|
postData = req.Body
|
||||||
} else if req.API == "_bulk" {
|
} else if req.API == "_bulk" {
|
||||||
postData = req.BulkData
|
postData = req.BulkData
|
||||||
} else {
|
} else if req.Body != nil {
|
||||||
b, err := json.Marshal(req.Query)
|
b, err := json.Marshal(req.Query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -90,14 +90,12 @@ func (req *Request) Request() (*http.Request, error) {
|
|||||||
postData = b
|
postData = b
|
||||||
}
|
}
|
||||||
|
|
||||||
reader := ioutil.NopCloser(bytes.NewReader(postData))
|
|
||||||
|
|
||||||
newReq, err := http.NewRequest(req.Method, "", nil)
|
newReq, err := http.NewRequest(req.Method, "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newReq.URL = req.URL()
|
newReq.URL = req.URL()
|
||||||
newReq.Body = reader
|
newReq.Body = ioutil.NopCloser(bytes.NewReader(postData))
|
||||||
newReq.ContentLength = int64(len(postData))
|
newReq.ContentLength = int64(len(postData))
|
||||||
|
|
||||||
if req.Method == "POST" || req.Method == "PUT" {
|
if req.Method == "POST" || req.Method == "PUT" {
|
||||||
|
Loading…
Reference in New Issue
Block a user