Skip to content

Commit

Permalink
fix: check responseContent in responseBody
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneBad authored and moshloop committed Dec 9, 2024
1 parent 576fdb2 commit 69f48c9
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions checks/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 69f48c9

Please sign in to comment.