Skip to content

Commit 61fba51

Browse files
authored
fix(idtoken): don't assume DefaultTransport is a http.Transport (#3263)
Fixes: #3260
1 parent b792200 commit 61fba51

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

idtoken/idtoken.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ func NewClient(ctx context.Context, audience string, opts ...ClientOption) (*htt
6868
// Skip DialSettings validation so added TokenSource will not conflict with user
6969
// provided credentials.
7070
opts = append(opts, option.WithTokenSource(ts), internaloption.SkipDialSettingsValidation())
71-
httpTransport := http.DefaultTransport.(*http.Transport).Clone()
72-
httpTransport.MaxIdleConnsPerHost = 100
73-
t, err := htransport.NewTransport(ctx, httpTransport, opts...)
71+
defaultTrans := http.DefaultTransport
72+
if trans, ok := defaultTrans.(*http.Transport); ok {
73+
defaultTrans = trans.Clone()
74+
defaultTrans.(*http.Transport).MaxIdleConnsPerHost = 100
75+
}
76+
t, err := htransport.NewTransport(ctx, defaultTrans, opts...)
7477
if err != nil {
7578
return nil, err
7679
}

0 commit comments

Comments
 (0)