fix(http): drain and close response bodies EE-5486 (#8933)

This commit is contained in:
andres-portainer
2023-05-12 17:55:27 -03:00
committed by GitHub
parent 5b96136dd2
commit 511adabce2
3 changed files with 21 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ package chisel
import (
"context"
"fmt"
"io"
"net/http"
"sync"
"time"
@@ -58,7 +59,11 @@ func (service *Service) pingAgent(endpointID portainer.EndpointID) error {
httpClient := &http.Client{
Timeout: 3 * time.Second,
}
_, err = httpClient.Do(req)
resp, err := httpClient.Do(req)
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
return err
}