mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 00:43:49 +01:00
9f24639568
Supported by all remotes except FTP.
30 lines
627 B
Go
30 lines
627 B
Go
// HTTP parts go1.7+
|
|
|
|
//+build go1.7
|
|
|
|
package fs
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// dial with context and timeouts
|
|
func (ci *ConfigInfo) dialContextTimeout(ctx context.Context, network, address string) (net.Conn, error) {
|
|
dialer := ci.NewDialer()
|
|
c, err := dialer.DialContext(ctx, network, address)
|
|
if err != nil {
|
|
return c, err
|
|
}
|
|
return newTimeoutConn(c, ci.Timeout), nil
|
|
}
|
|
|
|
// Initialise the http.Transport for go1.7+
|
|
func (ci *ConfigInfo) initTransport(t *http.Transport) {
|
|
t.DialContext = ci.dialContextTimeout
|
|
t.IdleConnTimeout = 60 * time.Second
|
|
t.ExpectContinueTimeout = ci.ConnectTimeout
|
|
}
|