From 0acf7fc8e970dc7472eed6040307f54da69ff37b Mon Sep 17 00:00:00 2001 From: Toni Solarin-Sodara Date: Thu, 31 Mar 2022 00:19:11 +0100 Subject: [PATCH] Check error when reading body --- modules/http-helper/http_helper.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/http-helper/http_helper.go b/modules/http-helper/http_helper.go index fcf893141..7d9e1361a 100644 --- a/modules/http-helper/http_helper.go +++ b/modules/http-helper/http_helper.go @@ -347,9 +347,13 @@ func HTTPDoWithRetryWithOptionsE( t testing.TestingT, options HttpDoOptions, expectedStatus int, retries int, sleepBetweenRetries time.Duration, ) (string, error) { - // The request body is closed after a request is complete. options. + // The request body is closed after a request is complete. // Extract the underlying data and cache it so we can reuse for retried requests data, err := io.ReadAll(options.Body) + if err != nil { + return "", err + } + options.Body = nil out, err := retry.DoWithRetryE(