mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
all: call Close() after reading http.Response.Body
As the doc of http.Response.Body says: // The http Client and Transport guarantee that Body is always // non-nil, even on responses without a body or responses with // a zero-length body. It is the caller's responsibility to // close Body. Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
parent
9359aef3e3
commit
bc31162cc2
@ -69,6 +69,7 @@ func write(key string, value string, version int64) error {
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read request body: %s", err)
|
||||
}
|
||||
httpResp.Body.Close()
|
||||
|
||||
resp := new(response)
|
||||
err = json.Unmarshal(respBytes, resp)
|
||||
|
@ -103,6 +103,7 @@ func TestNewPeerHandlerOnRaftPrefix(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected io.ReadAll error: %v", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
if w := "test data"; string(body) != w {
|
||||
t.Errorf("#%d: body = %s, want %s", i, body, w)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user