本文整理汇总了Golang中net/http.Transport.TLSHandshakeTimeout方法的典型用法代码示例。如果您正苦于以下问题:Golang Transport.TLSHandshakeTimeout方法的具体用法?Golang Transport.TLSHandshakeTimeout怎么用?Golang Transport.TLSHandshakeTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http.Transport
的用法示例。
在下文中一共展示了Transport.TLSHandshakeTimeout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetTransportDefaults
// SetTransportDefaults applies the defaults from http.DefaultTransport
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SetTransportDefaults(t *http.Transport) *http.Transport {
if t.Proxy == nil {
t.Proxy = defaultTransport.Proxy
}
if t.Dial == nil {
t.Dial = defaultTransport.Dial
}
if t.TLSHandshakeTimeout == 0 {
t.TLSHandshakeTimeout = defaultTransport.TLSHandshakeTimeout
}
return t
}
示例2: SetOldTransportDefaults
// SetOldTransportDefaults applies the defaults from http.DefaultTransport
// for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SetOldTransportDefaults(t *http.Transport) *http.Transport {
if t.Proxy == nil || isDefault(t.Proxy) {
// http.ProxyFromEnvironment doesn't respect CIDRs and that makes it impossible to exclude things like pod and service IPs from proxy settings
// ProxierWithNoProxyCIDR allows CIDR rules in NO_PROXY
t.Proxy = NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
}
if t.Dial == nil {
t.Dial = defaultTransport.Dial
}
if t.TLSHandshakeTimeout == 0 {
t.TLSHandshakeTimeout = defaultTransport.TLSHandshakeTimeout
}
return t
}
示例3: newHttpClient
func newHttpClient(config *Config) *http.Client {
transport := new(http.Transport)
if defaultTransport, ok := http.DefaultTransport.(*http.Transport); ok {
transport.Proxy = defaultTransport.Proxy
transport.Dial = defaultTransport.Dial
transport.TLSHandshakeTimeout = defaultTransport.TLSHandshakeTimeout
}
if config.ProxyHost != "" {
host := config.ProxyHost
if config.ProxyPort > 0 {
host += ":" + strconv.Itoa(config.ProxyPort)
}
proxyUrl, err := url.Parse(util.HostToURL(host, "http"))
if err != nil {
panic(err)
}
transport.Proxy = http.ProxyURL(proxyUrl)
}
/*
if c.ConnectionTimeout > 0 {
transport.TLSHandshakeTimeout = c.ConnectionTimeout
}
*/
if config.MaxConnections > 0 {
transport.MaxIdleConnsPerHost = config.MaxConnections
}
return &http.Client{
Transport: transport,
Timeout: config.Timeout,
}
}
示例4: Transport
// Transport returns an http.RoundTripper with the correct timeouts
func (ci *ConfigInfo) Transport() http.RoundTripper {
noTransport.Do(func() {
// Start with a sensible set of defaults then override.
// This also means we get new stuff when it gets added to go
t := new(http.Transport)
setDefaults(t, http.DefaultTransport.(*http.Transport))
t.Proxy = http.ProxyFromEnvironment
t.MaxIdleConnsPerHost = 4 * (ci.Checkers + ci.Transfers + 1)
t.TLSHandshakeTimeout = ci.ConnectTimeout
t.ResponseHeaderTimeout = ci.Timeout
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}
t.DisableCompression = *noGzip
// Set in http_old.go initTransport
// t.Dial
// Set in http_new.go initTransport
// t.DialContext
// t.IdelConnTimeout
// t.ExpectContinueTimeout
ci.initTransport(t)
// Wrap that http.Transport in our own transport
transport = NewTransport(t, ci.DumpHeaders, ci.DumpBodies)
})
return transport
}