2016-09-10 20:17:43 +02:00
|
|
|
// HTTP parts go1.7+
|
|
|
|
|
|
|
|
//+build go1.7
|
|
|
|
|
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// dial with context and timeouts
|
2017-07-23 17:10:23 +02:00
|
|
|
func (ci *ConfigInfo) dialContextTimeout(ctx context.Context, network, address string) (net.Conn, error) {
|
|
|
|
dialer := ci.NewDialer()
|
2016-09-10 20:17:43 +02:00
|
|
|
c, err := dialer.DialContext(ctx, network, address)
|
|
|
|
if err != nil {
|
|
|
|
return c, err
|
|
|
|
}
|
2017-07-23 17:10:23 +02:00
|
|
|
return newTimeoutConn(c, ci.Timeout), nil
|
2016-09-10 20:17:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initialise the http.Transport for go1.7+
|
|
|
|
func (ci *ConfigInfo) initTransport(t *http.Transport) {
|
2017-07-23 17:10:23 +02:00
|
|
|
t.DialContext = ci.dialContextTimeout
|
2016-09-10 20:17:43 +02:00
|
|
|
t.IdleConnTimeout = 60 * time.Second
|
|
|
|
t.ExpectContinueTimeout = ci.ConnectTimeout
|
|
|
|
}
|