Skip to content

Commit 99bbbc0

Browse files
wzshimingfjl
andauthored
internal/build, rpc: add missing HTTP response body Close() calls (ethereum#29223)
Co-authored-by: Felix Lange <[email protected]>
1 parent 89cefe2 commit 99bbbc0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/build/download.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
8484
resp, err := http.Get(url)
8585
if err != nil {
8686
return fmt.Errorf("download error: %v", err)
87-
} else if resp.StatusCode != http.StatusOK {
88-
return fmt.Errorf("download error: status %d", resp.StatusCode)
8987
}
9088
defer resp.Body.Close()
89+
90+
if resp.StatusCode != http.StatusOK {
91+
return fmt.Errorf("download error: status %d", resp.StatusCode)
92+
}
9193
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
9294
return err
9395
}

rpc/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
236236
if _, err := buf.ReadFrom(resp.Body); err == nil {
237237
body = buf.Bytes()
238238
}
239-
239+
resp.Body.Close()
240240
return nil, HTTPError{
241241
Status: resp.Status,
242242
StatusCode: resp.StatusCode,

0 commit comments

Comments
 (0)