Merge pull request #17634 from callthingsoff/httpresponse_close_after_read

all: call Close() after reading http.Response.Body
This commit is contained in:
Benjamin Wang 2024-03-25 07:03:54 +00:00 committed by GitHub
commit e4448c4744
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -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)

View File

@ -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)
}