Skip to content

Commit

Permalink
Merge pull request btcsuite#2256 from ziggie1984/timeout-https-client
Browse files Browse the repository at this point in the history
rpcclient: add timeout to http request.
  • Loading branch information
guggero authored Oct 11, 2024
2 parents ee68dc6 + 44c874f commit 24eb815
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpcclient/infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const (
// requestRetryInterval is the initial amount of time to wait in between
// retries when sending HTTP POST requests.
requestRetryInterval = time.Millisecond * 500

// defaultHTTPTimeout is the default timeout for an http request, so the
// request does not block indefinitely.
defaultHTTPTimeout = time.Minute
)

// jsonRequest holds information about a json request that is used to properly
Expand Down Expand Up @@ -1363,6 +1367,7 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) {
return net.Dial(parsedAddr.Network(), parsedAddr.String())
},
},
Timeout: defaultHTTPTimeout,
}

return &client, nil
Expand Down

0 comments on commit 24eb815

Please sign in to comment.