diff --git a/client-s3.go b/client-s3.go index 7bc279c2..4e72ddc8 100644 --- a/client-s3.go +++ b/client-s3.go @@ -20,7 +20,6 @@ import ( "errors" "hash/fnv" "io" - "net" "net/http" "net/url" "os" @@ -105,38 +104,23 @@ func newFactory() func(config *Config) (Client, *probe.Error) { if e != nil { return nil, probe.NewError(e) } + if config.Debug { + transport := http.DefaultTransport + if config.Signature == "S3v4" { + transport = httptracer.GetNewTraceTransport(newTraceV4(), http.DefaultTransport) + } + if config.Signature == "S3v2" { + transport = httptracer.GetNewTraceTransport(newTraceV2(), http.DefaultTransport) + } + // Set custom transport. + api.SetCustomTransport(transport) + } // Cache the new minio client with hash of config as key. clientCache[confSum] = api } // Set app info. api.SetAppInfo(config.AppName, config.AppVersion) - if config.Debug { - transport := http.DefaultTransport - if config.Signature == "S3v4" { - transport = httptracer.GetNewTraceTransport(newTraceV4(), http.DefaultTransport) - } - if config.Signature == "S3v2" { - transport = httptracer.GetNewTraceTransport(newTraceV2(), http.DefaultTransport) - } - // Set custom transport. - api.SetCustomTransport(transport) - } else { - // We are using our own http.Transport value to have timeouts different from default - // where necessary. - mcDefaultTransport := http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - //Default ExpectContinueTimeout is 1sec - ExpectContinueTimeout: 3 * time.Second, - ResponseHeaderTimeout: 3 * time.Second, - } - api.SetCustomTransport(&mcDefaultTransport) - } // Store the new api object. s3Clnt.api = api