Remove builds conditional on go1.7 since that is now guaranteed #2154

Old fallback code was deleted and the go1.7 style code inlined where
appropriate.
This commit is contained in:
Nick Craig-Wood 2018-04-06 20:33:51 +01:00
parent e5be471ce0
commit be54fd8f70
35 changed files with 45 additions and 157 deletions

View file

@ -108,6 +108,16 @@ func setDefaults(a, b interface{}) {
}
}
// dial with context and timeouts
func dialContextTimeout(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
dialer := NewDialer(ci)
c, err := dialer.DialContext(ctx, network, address)
if err != nil {
return c, err
}
return newTimeoutConn(c, ci.Timeout)
}
// NewTransport returns an http.RoundTripper with the correct timeouts
func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
noTransport.Do(func() {
@ -121,13 +131,11 @@ func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
t.ResponseHeaderTimeout = ci.Timeout
t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}
t.DisableCompression = ci.NoGzip
// Set in http_old.go initTransport
// t.Dial
// Set in http_new.go initTransport
// t.DialContext
// t.IdelConnTimeout
// t.ExpectContinueTimeout
initTransport(ci, t)
t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
return dialContextTimeout(ctx, network, addr, ci)
}
t.IdleConnTimeout = 60 * time.Second
t.ExpectContinueTimeout = ci.ConnectTimeout
// Wrap that http.Transport in our own transport
transport = newTransport(ci, t)
})