Sfoglia il codice sorgente

fix health check unclosed resp body, fix #1155

fatedier 6 anni fa
parent
commit
9ac8f2a047
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      client/health/health.go

+ 4 - 0
client/health/health.go

@@ -18,6 +18,8 @@ import (
 	"context"
 	"errors"
 	"fmt"
+	"io"
+	"io/ioutil"
 	"net"
 	"net/http"
 	"time"
@@ -170,6 +172,8 @@ func (monitor *HealthCheckMonitor) doHttpCheck(ctx context.Context) error {
 	if err != nil {
 		return err
 	}
+	defer resp.Body.Close()
+	io.Copy(ioutil.Discard, resp.Body)
 
 	if resp.StatusCode/100 != 2 {
 		return fmt.Errorf("do http health check, StatusCode is [%d] not 2xx", resp.StatusCode)