mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
Close the body after reading the response body information (#5907)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
@@ -61,6 +61,7 @@ func TestCustomHTTPRequestValidator(t *testing.T) {
|
|||||||
if res.StatusCode != tc.expected {
|
if res.StatusCode != tc.expected {
|
||||||
t.Error("unexpected HTTP code", res.StatusCode)
|
t.Error("unexpected HTTP code", res.StatusCode)
|
||||||
}
|
}
|
||||||
|
res.Body.Close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ func TestReloadMetricsHealth(t *testing.T) {
|
|||||||
}
|
}
|
||||||
const proc = "coredns_build_info"
|
const proc = "coredns_build_info"
|
||||||
metrics, _ := io.ReadAll(resp.Body)
|
metrics, _ := io.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
if !bytes.Contains(metrics, []byte(proc)) {
|
if !bytes.Contains(metrics, []byte(proc)) {
|
||||||
t.Errorf("Failed to see %s in metric output", proc)
|
t.Errorf("Failed to see %s in metric output", proc)
|
||||||
}
|
}
|
||||||
@@ -135,6 +136,7 @@ func collectMetricsInfo(addr string, procs ...string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
metrics, _ := io.ReadAll(resp.Body)
|
metrics, _ := io.ReadAll(resp.Body)
|
||||||
|
resp.Body.Close()
|
||||||
for _, p := range procs {
|
for _, p := range procs {
|
||||||
if !bytes.Contains(metrics, []byte(p)) {
|
if !bytes.Contains(metrics, []byte(p)) {
|
||||||
return fmt.Errorf("failed to see %s in metric output \n%s", p, metrics)
|
return fmt.Errorf("failed to see %s in metric output \n%s", p, metrics)
|
||||||
|
|||||||
Reference in New Issue
Block a user