Fix bug in setting request body
Go documentation says `Use of GetBody still requires setting Body`. This change ensures the body is always set in addition to GetBody. This fixes a bug where sometimes the body is nil. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -495,6 +495,11 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
|
||||
}
|
||||
req.Header = r.header
|
||||
if r.body != nil {
|
||||
body, err := r.body()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Body = body
|
||||
req.GetBody = r.body
|
||||
if r.size > 0 {
|
||||
req.ContentLength = r.size
|
||||
|
||||
Reference in New Issue
Block a user