From 6b4f2ed2ced397bd35c4ff31a2abf5a1d850d7af Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Mon, 14 Jul 2014 10:26:21 -0700 Subject: [PATCH] Use default client rather than a new client instance. --- google/google.go | 2 +- jwt.go | 3 +-- oauth2.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/google/google.go b/google/google.go index 292c315..f83d246 100644 --- a/google/google.go +++ b/google/google.go @@ -76,7 +76,7 @@ func (c *ComputeEngineConfig) FetchToken(existing *oauth2.Token) (token *oauth2. return } req.Header.Add("X-Google-Metadata-Request", "True") - resp, err := (&http.Client{}).Do(req) + resp, err := http.DefaultClient.Do(req) if err != nil { return } diff --git a/jwt.go b/jwt.go index d35be52..cd8280c 100644 --- a/jwt.go +++ b/jwt.go @@ -100,8 +100,7 @@ func (c *JWTConfig) FetchToken(existing *Token) (token *Token, err error) { v.Set("assertion", payload) // Make a request with assertion to get a new token. - client := http.Client{} - resp, err := client.PostForm(c.aud, v) + resp, err := http.DefaultClient.PostForm(c.aud, v) if err != nil { return nil, err } diff --git a/oauth2.go b/oauth2.go index 2d3d778..09783d7 100644 --- a/oauth2.go +++ b/oauth2.go @@ -206,7 +206,7 @@ func (c *Config) exchange(exchangeCode string) (*Token, error) { func (c *Config) updateToken(tok *Token, v url.Values) error { v.Set("client_id", c.opts.ClientID) v.Set("client_secret", c.opts.ClientSecret) - r, err := (&http.Client{}).PostForm(c.tokenURL, v) + r, err := http.DefaultClient.PostForm(c.tokenURL, v) if err != nil { return err }