func ClientWithTimeout(timeout time.Duration) *http.Client {
	transport := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: func(netw, addr string) (net.Conn, error) {
			c, err := net.DialTimeout(netw, addr, timeout)
			if err != nil {
				return nil, err
			}
			if tc, ok := c.(*net.TCPConn); ok {
				tc.SetKeepAlive(true)
				tc.SetKeepAlivePeriod(timeout)
			}
			return &deadlineConn{timeout, c}, nil
		},
		ResponseHeaderTimeout: timeout,
		MaxIdleConnsPerHost:   10,
	}
	return &http.Client{Transport: transport}
}
func ClientWithTimeout(timeout time.Duration) *http.Client {
	transport := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		Dial: func(netw, addr string) (net.Conn, error) {
			c, err := net.DialTimeout(netw, addr, timeout)
			if err != nil {
				return nil, err
			}
			if tc, ok := c.(*net.TCPConn); ok {
				tc.SetKeepAlive(true)
				tc.SetKeepAlivePeriod(timeout)
			}
			return &deadlineConn{timeout, c}, nil
		},
		ResponseHeaderTimeout: timeout,
		MaxIdleConnsPerHost:   10,
	}
	return &http.Client{Transport: transport}
}
func ClientWithTimeout ( timeout time . Duration ) * http . Client { transport := & http . Transport { Proxy : http . ProxyFromEnvironment , Dial : func ( netw , addr string ) ( net . Conn , error ) { c , err := net . DialTimeout ( netw , addr , timeout ) if err != nil { return nil , err } if tc , ok := c . ( * net . TCPConn ) ; ok { tc . SetKeepAlive ( true ) tc . SetKeepAlivePeriod ( timeout ) } return & deadlineConn { timeout , c } , nil } , ResponseHeaderTimeout : timeout , MaxIdleConnsPerHost : 10 , } return & http . Client { Transport : transport } }
// ClientWithTimeout is an http client optimized for high throughput
// to S3, It times out more agressively than the default
// http client in net/http as well as setting deadlines on the TCP connection
ClientWithTimeout is an http client optimized for high throughput to S3 It times out more agressively than the default http client in net / http as well as setting deadlines on the TCP connection