func TestContextClient(t *testing.T) { rc := &http.Client{} RegisterContextClientFunc(func(context.Context) (*http.Client, error) { return rc, nil }) c := &http.Client{} ctx := context.WithValue(nil, HTTPClient, c) hc, err := ContextClient(ctx) if err != nil { t.Fatalf("want valid client; got err = %v", err) } if hc != c { t.Fatalf("want context client = %p; got = %p", c, hc) } hc, err = ContextClient(context.TODO()) if err != nil { t.Fatalf("want valid client; got err = %v", err) } if hc != rc { t.Fatalf("want registered client = %p; got = %p", c, hc) } }
import ( "bytes" "errors" "net/http" "net/url" "strings" "sync" "github.com/MustWin/relevant_hunters/Godeps/_workspace/src/golang.org/x/net/context" "github.com/MustWin/relevant_hunters/Godeps/_workspace/src/golang.org/x/oauth2/internal" ) // NoContext is the default context you should supply if not using // your own context.Context (see https://golang.org/x/net/context). var NoContext = context.TODO() // RegisterBrokenAuthHeaderProvider registers an OAuth2 server // identified by the tokenURL prefix as an OAuth2 implementation // which doesn't support the HTTP Basic authentication // scheme to authenticate with the authorization server. // Once a server is registered, credentials (client_id and client_secret) // will be passed as query parameters rather than being present // in the Authorization header. // See https://code.google.com/p/goauth2/issues/detail?id=31 for background. func RegisterBrokenAuthHeaderProvider(tokenURL string) { internal.RegisterBrokenAuthHeaderProvider(tokenURL) } // Config describes a typical 3-legged OAuth2 flow, with both the // client application information and the server's endpoint URLs.