From a8cf79c530faca9b6513dd148372d4655414a715 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Sat, 2 Dec 2023 14:09:30 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20checker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/checker/ping.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/checker/ping.go b/apps/checker/ping.go index 8c55c77694..7d8dfcb97d 100644 --- a/apps/checker/ping.go +++ b/apps/checker/ping.go @@ -85,7 +85,6 @@ func ping(client *http.Client, inputData InputData) (PingData, error) { latency := time.Since(start).Milliseconds() defer response.Body.Close() - _, err = io.ReadAll(response.Body) if err != nil { if urlErr, ok := err.(*url.Error); ok { if urlErr.Timeout() { @@ -101,9 +100,14 @@ func ping(client *http.Client, inputData InputData) (PingData, error) { } } - return PingData{}, fmt.Errorf("Error while reading body from %s: %w", inputData.Url, err) + return PingData{}, fmt.Errorf("Error with monitor %s: %w", inputData.Url, err) } + _, err = io.ReadAll(response.Body) + + if err != nil { + return PingData{}, fmt.Errorf("Error while reading body from %s: %w", inputData.Url, err) + } return PingData{ Latency: latency, StatusCode: response.StatusCode,