refactor(provider): always clone default HTTP transport in S3 provider (#4132)

The s3 storage provider had a different http transports for different cases:

- https without TLS verification: `&http.Transport{}` with default values;
- https with TLS verification: `http.DefaultTransport.Clone()`

This change uses `http.DefaultTransport` in all cases, instead of creating an
empty (zero-value) `http.Transport` for consistency.

Authored-by: aleksandr.samarin (@alexvbg)
This commit is contained in:
Julio López
2024-09-26 21:51:07 -07:00
committed by GitHub
parent 1bceb7155e
commit b60804198c

View File

@@ -301,12 +301,14 @@ func (s *s3Storage) DisplayName() string {
}
func getCustomTransport(opt *Options) (*http.Transport, error) {
transport := http.DefaultTransport.(*http.Transport).Clone() //nolint:forcetypeassert
if opt.DoNotVerifyTLS {
//nolint:gosec
return &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}, nil
}
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
transport := http.DefaultTransport.(*http.Transport).Clone() //nolint:forcetypeassert
return transport, nil
}
if len(opt.RootCA) != 0 {
rootcas := x509.NewCertPool()