EventExporter( Elastic ) Close the body of response in defer and after verify the error

This commit is contained in:
TeoV
2020-10-23 15:51:12 +03:00
committed by Dan Christian Bogos
parent 2d609fb677
commit e616f64035

View File

@@ -189,9 +189,10 @@ func (eEe *ElasticEe) ExportEvent(cgrEv *utils.CGREventWithOpts) (err error) {
var resp *esapi.Response
if resp, err = eReq.Do(context.Background(), eEe.eClnt); err != nil {
resp.Body.Close()
return
} else if resp.IsError() {
}
defer resp.Body.Close()
if resp.IsError() {
var e map[string]interface{}
if err = json.NewDecoder(resp.Body).Decode(&e); err != nil {
return