mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #17634 from callthingsoff/httpresponse_close_after_read
all: call Close() after reading http.Response.Body
This commit is contained in:
commit
e4448c4744
@ -69,6 +69,7 @@ func write(key string, value string, version int64) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to read request body: %s", err)
|
log.Fatalf("failed to read request body: %s", err)
|
||||||
}
|
}
|
||||||
|
httpResp.Body.Close()
|
||||||
|
|
||||||
resp := new(response)
|
resp := new(response)
|
||||||
err = json.Unmarshal(respBytes, resp)
|
err = json.Unmarshal(respBytes, resp)
|
||||||
|
@ -103,6 +103,7 @@ func TestNewPeerHandlerOnRaftPrefix(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected io.ReadAll error: %v", err)
|
t.Fatalf("unexpected io.ReadAll error: %v", err)
|
||||||
}
|
}
|
||||||
|
resp.Body.Close()
|
||||||
if w := "test data"; string(body) != w {
|
if w := "test data"; string(body) != w {
|
||||||
t.Errorf("#%d: body = %s, want %s", i, body, w)
|
t.Errorf("#%d: body = %s, want %s", i, body, w)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user