diff --git a/pkg/client/client.go b/pkg/client/client.go index 2228d8f6..e172ef3b 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -447,7 +447,11 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { - err = xml.NewEncoder(bodyBuf).Encode(body) + enc := xml.NewEncoder(bodyBuf) + err = enc.Encode(body) + if closeErr := enc.Close(); closeErr != nil { + err = fmt.Errorf("%v: close error %v", err, closeErr) + } } if err != nil {