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, "")
|
creds = credentials.NewStaticV2(config.AccessKey, config.SecretKey, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var transport http.RoundTripper
|
||||||
|
|
||||||
|
if config.Transport != nil {
|
||||||
|
transport = config.Transport
|
||||||
|
} else {
|
||||||
tr := &http.Transport{
|
tr := &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
DialContext: (&net.Dialer{
|
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
|
// https://golang.org/src/net/http/transport.go?h=roundTrip#L1843
|
||||||
DisableCompression: true,
|
DisableCompression: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if useTLS {
|
if useTLS {
|
||||||
// Keep TLS config.
|
// Keep TLS config.
|
||||||
tlsConfig := &tls.Config{
|
tlsConfig := &tls.Config{
|
||||||
@@ -179,8 +183,9 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
|||||||
// return nil, probe.NewError(e)
|
// return nil, probe.NewError(e)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
transport = tr
|
||||||
|
}
|
||||||
|
|
||||||
var transport http.RoundTripper = tr
|
|
||||||
if config.Debug {
|
if config.Debug {
|
||||||
if strings.EqualFold(config.Signature, "S3v4") {
|
if strings.EqualFold(config.Signature, "S3v4") {
|
||||||
transport = httptracer.GetNewTraceTransport(newTraceV4(), transport)
|
transport = httptracer.GetNewTraceTransport(newTraceV4(), transport)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -194,6 +195,7 @@ type Config struct {
|
|||||||
Debug bool
|
Debug bool
|
||||||
Insecure bool
|
Insecure bool
|
||||||
Lookup minio.BucketLookupType
|
Lookup minio.BucketLookupType
|
||||||
|
Transport *http.Transport
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectObjectOpts - opts entered for select API
|
// SelectObjectOpts - opts entered for select API
|
||||||
|
|||||||
Reference in New Issue
Block a user