forked from remote/oauth2
internal: primarily use the HTTP client provided in the context
Change-Id: I99eaf1480ebdfbaa5b64ac17203fbf14bf887962 Reviewed-on: https://go-review.googlesource.com/17396 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Chris Broadfoot <cbro@golang.org>
This commit is contained in:
@@ -33,6 +33,11 @@ func RegisterContextClientFunc(fn ContextClientFunc) {
|
||||
}
|
||||
|
||||
func ContextClient(ctx context.Context) (*http.Client, error) {
|
||||
if ctx != nil {
|
||||
if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
|
||||
return hc, nil
|
||||
}
|
||||
}
|
||||
for _, fn := range contextClientFuncs {
|
||||
c, err := fn(ctx)
|
||||
if err != nil {
|
||||
@@ -42,9 +47,6 @@ func ContextClient(ctx context.Context) (*http.Client, error) {
|
||||
return c, nil
|
||||
}
|
||||
}
|
||||
if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok {
|
||||
return hc, nil
|
||||
}
|
||||
return http.DefaultClient, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user