func (c *Consumer) preventRedirects(client *httpclient.Client) { if client != nil { httpClient := client.HTTPClient() if httpClient.CheckRedirect == nil { httpClient.CheckRedirect = preventRedirect } } }
func testUserAgent(t *testing.T, c *httpclient.Client, exp string) { ep := urlutil.MustJoin(httpBin, "/user-agent") resp, err := c.Get(ep) if err != nil { t.Fatal(err) } defer resp.Close() var m map[string]interface{} if err := resp.DecodeJSON(&m); err != nil { t.Fatal(err) } ua := m["user-agent"].(string) if idx := strings.Index(ua, " AppEngine-Google"); idx >= 0 { ua = ua[:idx] } if ua != exp { t.Errorf("expecting User-Agent %q, got %q instead", exp, ua) } }