-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathhttp.go
More file actions
30 lines (28 loc) · 829 Bytes
/
http.go
File metadata and controls
30 lines (28 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package githubauth
import (
"net"
"net/http"
"runtime"
"time"
)
// cleanHTTPClient returns a new http.Client with clean defaults and connection pooling.
// Implementation based on github.com/hashicorp/go-cleanhttp
// Licensed under MPL-2.0: https://github.com/hashicorp/go-cleanhttp/blob/master/LICENSE
func cleanHTTPClient() *http.Client {
return &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
ForceAttemptHTTP2: true,
MaxIdleConnsPerHost: runtime.GOMAXPROCS(0) + 1,
},
}
}