diff --git a/v2/pkg/executer/executer_http.go b/v2/pkg/executer/executer_http.go index 68e9e073..1b271a8b 100644 --- a/v2/pkg/executer/executer_http.go +++ b/v2/pkg/executer/executer_http.go @@ -317,6 +317,9 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest, if request.Pipeline { resp, err = request.PipelineClient.DoRaw(request.RawRequest.Method, reqURL, request.RawRequest.Path, requests.ExpandMapValues(request.RawRequest.Headers), ioutil.NopCloser(strings.NewReader(request.RawRequest.Data))) if err != nil { + if resp != nil { + resp.Body.Close() + } return err } } else if request.Unsafe { @@ -328,6 +331,9 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest, options.AutomaticHostHeader = request.AutomaticHostHeader resp, err = e.rawHTTPClient.DoRawWithOptions(request.RawRequest.Method, reqURL, request.RawRequest.Path, requests.ExpandMapValues(request.RawRequest.Headers), ioutil.NopCloser(strings.NewReader(request.RawRequest.Data)), options) if err != nil { + if resp != nil { + resp.Body.Close() + } return err } } else { @@ -340,6 +346,7 @@ func (e *HTTPExecuter) handleHTTP(reqURL string, request *requests.HTTPRequest, return err } } + duration := time.Since(timeStart) if e.debug {