internal/build, rpc: add missing HTTP response body Close() calls (#29223)
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
89cefe240f
commit
99bbbc0277
@ -84,10 +84,12 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
|
|||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("download error: %v", err)
|
return fmt.Errorf("download error: %v", err)
|
||||||
} else if resp.StatusCode != http.StatusOK {
|
|
||||||
return fmt.Errorf("download error: status %d", resp.StatusCode)
|
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return fmt.Errorf("download error: status %d", resp.StatusCode)
|
||||||
|
}
|
||||||
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
|
|||||||
if _, err := buf.ReadFrom(resp.Body); err == nil {
|
if _, err := buf.ReadFrom(resp.Body); err == nil {
|
||||||
body = buf.Bytes()
|
body = buf.Bytes()
|
||||||
}
|
}
|
||||||
|
resp.Body.Close()
|
||||||
return nil, HTTPError{
|
return nil, HTTPError{
|
||||||
Status: resp.Status,
|
Status: resp.Status,
|
||||||
StatusCode: resp.StatusCode,
|
StatusCode: resp.StatusCode,
|
||||||
|
Loading…
Reference in New Issue
Block a user