From 8f029d83797ee2c58fd876ce778a04f2fa1745ca Mon Sep 17 00:00:00 2001 From: Armstrong Li Date: Wed, 21 Dec 2016 09:57:17 +0800 Subject: [PATCH] fix issue #621 endless recursion --- provider_client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/provider_client.go b/provider_client.go index 08fd0ca8..a47ea0cd 100644 --- a/provider_client.go +++ b/provider_client.go @@ -168,9 +168,6 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) ( } req.Header.Set("Accept", applicationJSON) - for k, v := range client.AuthenticatedHeaders() { - req.Header.Add(k, v) - } // Set the User-Agent header req.Header.Set("User-Agent", client.UserAgent.Join()) @@ -185,6 +182,11 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) ( } } + // get latest auth token + for k, v := range client.AuthenticatedHeaders() { + req.Header.Set(k, v) + } + // Set connection parameter to close the connection immediately when we've got the response req.Close = true