mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
Increase default timeout for SaneHttpClient, but fail early. (#587)
* Increase default timeout for SaneHttpClient, but fail early. * Don't change default for client with timeout
This commit is contained in:
parent
143fa333f3
commit
c52545a0d3
1 changed files with 16 additions and 2 deletions
|
@ -121,10 +121,24 @@ func RetryableHttpClient() *http.Client {
|
|||
return httpClient.StandardClient()
|
||||
}
|
||||
|
||||
const DefaultResponseTimeout = 5 * time.Second
|
||||
|
||||
var saneTransport = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 2 * time.Second,
|
||||
KeepAlive: 5 * time.Second,
|
||||
}).DialContext,
|
||||
MaxIdleConns: 5,
|
||||
IdleConnTimeout: 5 * time.Second,
|
||||
TLSHandshakeTimeout: 3 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
func SaneHttpClient() *http.Client {
|
||||
httpClient := &http.Client{}
|
||||
httpClient.Timeout = time.Second * 2
|
||||
httpClient.Transport = NewCustomTransport(nil)
|
||||
httpClient.Timeout = DefaultResponseTimeout
|
||||
httpClient.Transport = NewCustomTransport(saneTransport)
|
||||
return httpClient
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue