forked from cerc-io/plugeth
metrics/librato: ensure resp.body closed (#26969)
This change ensures that we call Close on a http response body, in various places in the source code (mostly tests)
This commit is contained in:
@@ -428,9 +428,11 @@ func execP2PNode() {
|
||||
|
||||
// Send status to the host.
|
||||
statusJSON, _ := json.Marshal(status)
|
||||
if _, err := http.Post(statusURL, "application/json", bytes.NewReader(statusJSON)); err != nil {
|
||||
resp, err := http.Post(statusURL, "application/json", bytes.NewReader(statusJSON))
|
||||
if err != nil {
|
||||
log.Crit("Can't post startup info", "url", statusURL, "err", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if stackErr != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ func TestMocker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Could not start mocker: %s", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
t.Fatalf("Invalid Status Code received for starting mocker, expected 200, got %d", resp.StatusCode)
|
||||
}
|
||||
@@ -145,15 +146,17 @@ func TestMocker(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Could not stop mocker: %s", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
t.Fatalf("Invalid Status Code received for stopping mocker, expected 200, got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
//reset the network
|
||||
_, err = http.Post(s.URL+"/reset", "", nil)
|
||||
resp, err = http.Post(s.URL+"/reset", "", nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Could not reset network: %s", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
||||
//now the number of nodes in the network should be zero
|
||||
nodesInfo, err = client.GetNodes()
|
||||
|
||||
Reference in New Issue
Block a user