Skip to content

Commit 0042180

Browse files
abeltaygopherbot
authored andcommitted
oauth2: Deep copy context client in NewClient
OAuth2 client creation currently doesn't faithfully reuse the client passed into the context. This causes config settings such as timeout to be set to Default and may end up to be a gotcha for anyone who sends in a context client with timeout set assuming that the timeout will be copied to the new client. Fix: #368 Change-Id: I4f5f052361ebe07f50fbd694379892833cd1056c Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/180920 Auto-Submit: Sean Liao <[email protected]> Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Junyang Shao <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent ce350bf commit 0042180

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

oauth2.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,15 @@ func NewClient(ctx context.Context, src TokenSource) *http.Client {
356356
if src == nil {
357357
return internal.ContextClient(ctx)
358358
}
359+
cc := internal.ContextClient(ctx)
359360
return &http.Client{
360361
Transport: &Transport{
361-
Base: internal.ContextClient(ctx).Transport,
362+
Base: cc.Transport,
362363
Source: ReuseTokenSource(nil, src),
363364
},
365+
CheckRedirect: cc.CheckRedirect,
366+
Jar: cc.Jar,
367+
Timeout: cc.Timeout,
364368
}
365369
}
366370

0 commit comments

Comments
 (0)