Merge pull request #2256 from ziggie1984/timeout-https-client

rpcclient: add timeout to http request.
This commit is contained in:
Oliver Gugger 2024-10-11 06:58:36 -06:00 committed by GitHub
commit 24eb815168
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
@ -1363,6 +1367,7 @@ func newHTTPClient(config *ConnConfig) (*http.Client, error) {
return net.Dial(parsedAddr.Network(), parsedAddr.String())
},
},
Timeout: defaultHTTPTimeout,
}
return &client, nil