From b7877632fe8963df9b3bbf84c8994b90d1acc3ce Mon Sep 17 00:00:00 2001 From: Eugene Badriku Date: Fri, 6 Dec 2024 15:54:01 +0100 Subject: [PATCH] fix: check responseContent in responseBody --- checks/http.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/checks/http.go b/checks/http.go index 85f6b5086..8f4655d56 100644 --- a/checks/http.go +++ b/checks/http.go @@ -147,14 +147,6 @@ func (c *HTTPChecker) generateHTTPRequest(ctx *context.Context, check v1.HTTPChe return client.R(ctx), nil } -func truncate(text string, max int) string { - length := len(text) - if length <= max { - return text - } - return text[0:max] -} - func (c *HTTPChecker) Check(ctx *context.Context, extConfig external.Check) pkg.Results { check := extConfig.(v1.HTTPCheck) var results pkg.Results @@ -324,8 +316,8 @@ func (c *HTTPChecker) Check(ctx *context.Context, extConfig external.Check) pkg. return results.Failf("threshold exceeded %s > %d", utils.Age(elapsed), check.ThresholdMillis) } - if check.ResponseContent != "" && !strings.Contains(body, check.ResponseContent) { - return results.Failf("expected %v, found %v", check.ResponseContent, truncate(body, 100)) + if check.ResponseContent != "" && !strings.Contains(responseBody, check.ResponseContent) { + return results.Failf("expected %v, found %v", check.ResponseContent, responseBody) } if check.MaxSSLExpiry > 0 {