From 57c316fb8dde3113564f030703c57570327e4e92 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Sat, 14 Sep 2024 14:36:35 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20small=20improvment=20(#1004)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/checker/ping.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/checker/ping.go b/apps/checker/ping.go index e4f4c61464..70506ca538 100644 --- a/apps/checker/ping.go +++ b/apps/checker/ping.go @@ -69,20 +69,22 @@ func Ping(ctx context.Context, client *http.Client, inputData request.CheckerReq region := os.Getenv("FLY_REGION") b := []byte(inputData.Body) - for _, header := range inputData.Headers { - if header.Key == "Content-Type" && header.Value == "application/octet-stream" { + if inputData.Method == http.MethodPost { + for _, header := range inputData.Headers { + if header.Key == "Content-Type" && header.Value == "application/octet-stream" { - // split the body by comma and convert it to bytes - data := strings.Split(inputData.Body, ",") - if len(data) == 2 { + // split the body by comma and convert it to bytes + data := strings.Split(inputData.Body, ",") + if len(data) == 2 { - decoded, err := base64.StdEncoding.DecodeString(data[1]) - if err != nil { - return PingData{}, fmt.Errorf("error while decoding base64: %w", err) - } + decoded, err := base64.StdEncoding.DecodeString(data[1]) + if err != nil { + return PingData{}, fmt.Errorf("error while decoding base64: %w", err) + } - b = decoded + b = decoded + } } } }