Skip to content

Commit

Permalink
close response bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
skylenet committed Aug 10, 2022
1 parent 7595ece commit cd09416
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/backends/beacon/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ func (b *Backend) checkNodeVersion() (string, error) {
client := http.Client{
Timeout: 10 * time.Second,
}
resp, err := client.Get(fmt.Sprintf("%s/eth/v1/node/version", b.url.String()))

resp, err := client.Get(fmt.Sprintf("%s/eth/v1/node/version", b.url.String()))
if err != nil {
return "", err
}

defer resp.Body.Close()

r := struct {
Data struct {
Version string `json:"version"`
Expand All @@ -189,6 +191,8 @@ func (b *Backend) checkNodeSyncing() (*SyncInfo, error) {
return nil, err
}

defer resp.Body.Close()

r := struct {
Data struct {
SyncInfo
Expand All @@ -213,6 +217,8 @@ func (b *Backend) checkNodePeerCount() (*PeerCountInfo, error) {
return nil, err
}

defer resp.Body.Close()

// Some clients return the fields as int, others as strings, so we have to deal with both cases
r := struct {
Data struct {
Expand Down

0 comments on commit cd09416

Please sign in to comment.