mirror of
https://github.com/rclone/rclone.git
synced 2026-01-04 17:43:50 +00:00
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:
@@ -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)
|
||||
})
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// HTTP parts go1.7+
|
||||
|
||||
//+build go1.7
|
||||
|
||||
package fshttp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// Initialise the http.Transport for go1.7+
|
||||
func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
|
||||
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
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// HTTP parts pre go1.7
|
||||
|
||||
//+build !go1.7
|
||||
|
||||
package fshttp
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
)
|
||||
|
||||
// dial with timeouts
|
||||
func dialTimeout(network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
|
||||
dialer := NewDialer(ci)
|
||||
c, err := dialer.Dial(network, address)
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
return newTimeoutConn(c, ci.Timeout)
|
||||
}
|
||||
|
||||
// Initialise the http.Transport for pre go1.7
|
||||
func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
|
||||
t.Dial = func(network, addr string) (net.Conn, error) {
|
||||
return dialTimeout(network, addr, ci)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
//+build go1.7
|
||||
|
||||
package fshttp
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user