1
mirror of https://github.com/rclone/rclone synced 2024-12-13 01:13:58 +01:00
rclone/fs/http_new.go
2017-07-23 16:27:39 +01:00

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
}