2019-04-16 15:25:54 +00:00
|
|
|
// Shared transports for all clients to prevent leaking connections
|
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// defaultTransport is the default implementation of Transport and is
|
|
|
|
// used by traceClient. It establishes network connections as needed
|
|
|
|
// and caches them for reuse by subsequent calls. It uses HTTP proxies
|
|
|
|
// as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and
|
|
|
|
// $no_proxy) environment variables.
|
2019-04-16 15:41:51 +00:00
|
|
|
// This is the same as http.DefaultTransport.
|
2019-04-16 15:25:54 +00:00
|
|
|
//
|
|
|
|
var defaultTransport http.RoundTripper = &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,
|
|
|
|
}
|
|
|
|
|
|
|
|
// skipVerifyTransport is the default implementation of Transport and is
|
2019-05-09 17:41:14 +00:00
|
|
|
// used by traceClient (NewClient with insecure set to true). It establishes network connections as needed
|
2019-04-16 15:25:54 +00:00
|
|
|
// and caches them for reuse by subsequent calls. It uses HTTP proxies
|
|
|
|
// as directed by the $HTTP_PROXY and $NO_PROXY (or $http_proxy and
|
|
|
|
// $no_proxy) environment variables.
|
2019-04-16 15:41:51 +00:00
|
|
|
// This is the same as http.DefaultTransport but with TLS skip verify.
|
2019-04-16 15:25:54 +00:00
|
|
|
//
|
|
|
|
var skipVerifyTransport = &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,
|
2019-04-16 15:41:51 +00:00
|
|
|
// This is the value that changes between this and http.DefaultTransport
|
|
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
2019-04-16 15:25:54 +00:00
|
|
|
}
|