|
|
|
@ -109,11 +109,13 @@ func NewHTTPGetter(options ...Option) (Getter, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *HTTPGetter) httpClient() (*http.Client, error) {
|
|
|
|
|
var transport *http.Transport
|
|
|
|
|
|
|
|
|
|
if g.opts.transport != nil {
|
|
|
|
|
transport = g.opts.transport
|
|
|
|
|
} else {
|
|
|
|
|
return &http.Client{
|
|
|
|
|
Transport: g.opts.transport,
|
|
|
|
|
Timeout: g.opts.timeout,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g.once.Do(func() {
|
|
|
|
|
g.transport = &http.Transport{
|
|
|
|
|
DisableCompression: true,
|
|
|
|
@ -121,9 +123,6 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
transport = g.transport
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (g.opts.certFile != "" && g.opts.keyFile != "") || g.opts.caFile != "" {
|
|
|
|
|
tlsConf, err := tlsutil.NewClientTLS(g.opts.certFile, g.opts.keyFile, g.opts.caFile)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -137,21 +136,21 @@ func (g *HTTPGetter) httpClient() (*http.Client, error) {
|
|
|
|
|
}
|
|
|
|
|
tlsConf.ServerName = sni
|
|
|
|
|
|
|
|
|
|
transport.TLSClientConfig = tlsConf
|
|
|
|
|
g.transport.TLSClientConfig = tlsConf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if g.opts.insecureSkipVerifyTLS {
|
|
|
|
|
if transport.TLSClientConfig == nil {
|
|
|
|
|
transport.TLSClientConfig = &tls.Config{
|
|
|
|
|
if g.transport.TLSClientConfig == nil {
|
|
|
|
|
g.transport.TLSClientConfig = &tls.Config{
|
|
|
|
|
InsecureSkipVerify: true,
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
transport.TLSClientConfig.InsecureSkipVerify = true
|
|
|
|
|
g.transport.TLSClientConfig.InsecureSkipVerify = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client := &http.Client{
|
|
|
|
|
Transport: transport,
|
|
|
|
|
Transport: g.transport,
|
|
|
|
|
Timeout: g.opts.timeout,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|