mirror of
https://github.com/minio/mc.git
synced 2025-11-29 19:43:09 +03:00
Support for setting custom Transport in S3Client configuration (#3510)
This commit is contained in:
@@ -137,6 +137,11 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
creds = credentials.NewStaticV2(config.AccessKey, config.SecretKey, "")
|
||||
}
|
||||
|
||||
var transport http.RoundTripper
|
||||
|
||||
if config.Transport != nil {
|
||||
transport = config.Transport
|
||||
} else {
|
||||
tr := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: (&net.Dialer{
|
||||
@@ -155,7 +160,6 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
// https://golang.org/src/net/http/transport.go?h=roundTrip#L1843
|
||||
DisableCompression: true,
|
||||
}
|
||||
|
||||
if useTLS {
|
||||
// Keep TLS config.
|
||||
tlsConfig := &tls.Config{
|
||||
@@ -179,8 +183,9 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
// return nil, probe.NewError(e)
|
||||
// }
|
||||
}
|
||||
transport = tr
|
||||
}
|
||||
|
||||
var transport http.RoundTripper = tr
|
||||
if config.Debug {
|
||||
if strings.EqualFold(config.Signature, "S3v4") {
|
||||
transport = httptracer.GetNewTraceTransport(newTraceV4(), transport)
|
||||
|
||||
@@ -19,6 +19,7 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -194,6 +195,7 @@ type Config struct {
|
||||
Debug bool
|
||||
Insecure bool
|
||||
Lookup minio.BucketLookupType
|
||||
Transport *http.Transport
|
||||
}
|
||||
|
||||
// SelectObjectOpts - opts entered for select API
|
||||
|
||||
Reference in New Issue
Block a user