Skip to content

Commit

Permalink
Close the body after reading the response body information (coredns#5907
Browse files Browse the repository at this point in the history
)

Signed-off-by: Fish-pro <[email protected]>
  • Loading branch information
Fish-pro authored Feb 15, 2023
1 parent 8a0d3ba commit 156da74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/dnsserver/server_https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestCustomHTTPRequestValidator(t *testing.T) {
if res.StatusCode != tc.expected {
t.Error("unexpected HTTP code", res.StatusCode)
}
res.Body.Close()
})
}
}
2 changes: 2 additions & 0 deletions test/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestReloadMetricsHealth(t *testing.T) {
}
const proc = "coredns_build_info"
metrics, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if !bytes.Contains(metrics, []byte(proc)) {
t.Errorf("Failed to see %s in metric output", proc)
}
Expand All @@ -135,6 +136,7 @@ func collectMetricsInfo(addr string, procs ...string) error {
return err
}
metrics, _ := io.ReadAll(resp.Body)
resp.Body.Close()
for _, p := range procs {
if !bytes.Contains(metrics, []byte(p)) {
return fmt.Errorf("failed to see %s in metric output \n%s", p, metrics)
Expand Down

0 comments on commit 156da74

Please sign in to comment.