From 4254dfb4af768c29923e08fc68907916c4fedbdc Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 15 Oct 2020 18:13:18 +0200 Subject: [PATCH] Read from an ioutil.ReadAll without losing HTTP response content (#46) --- pkg/resp_analysis.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/resp_analysis.go b/pkg/resp_analysis.go index e19fe68..9a9974d 100644 --- a/pkg/resp_analysis.go +++ b/pkg/resp_analysis.go @@ -1,6 +1,7 @@ package pkg import ( + "bytes" "gochopchop/data" "io/ioutil" "log" @@ -15,6 +16,9 @@ func ResponseAnalysis(resp *http.Response, signature data.Check) bool { if err != nil { log.Fatal(err) } + // Restore the io.ReadCloser to its original state + resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) + bodyString := string(bodyBytes) if signature.StatusCode != nil {