Replace usage of http.DefaultClient and http.DefaultTransport (#104135)
Remove usage of http.DefaultClient and http.DefaultTransport Part of grafana/data-sources#484
This commit is contained in:
@@ -3,7 +3,6 @@ package cloudwatch
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -324,14 +323,7 @@ func (ds *DataSource) newSession(region string) (*session.Session, error) {
|
||||
// only update the transport to try to avoid the issue mentioned here https://github.com/grafana/grafana/issues/46365
|
||||
// also, 'sess' is cached and reused, so the first time it might have the transport not set, the following uses it will
|
||||
if sess.Config.HTTPClient.Transport == nil {
|
||||
// following go standard library logic (https://pkg.go.dev/net/http#Client), if no Transport is provided,
|
||||
// then we use http.DefaultTransport
|
||||
defTransport, ok := http.DefaultTransport.(*http.Transport)
|
||||
if !ok {
|
||||
// this should not happen but validating just in case
|
||||
return nil, errors.New("default http client transport is not of type http.Transport")
|
||||
}
|
||||
sess.Config.HTTPClient.Transport = defTransport.Clone()
|
||||
sess.Config.HTTPClient.Transport = httpclient.NewHTTPTransport()
|
||||
}
|
||||
err = proxy.New(ds.ProxyOpts).ConfigureSecureSocksHTTPProxy(sess.Config.HTTPClient.Transport.(*http.Transport))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user