fix issue where go 1.8 would add duplicate Auth header
diff --git a/apigee_sync.go b/apigee_sync.go index d6b3a19..aa816bb 100644 --- a/apigee_sync.go +++ b/apigee_sync.go
@@ -86,12 +86,6 @@ } } -func Redirect(req *http.Request, _ []*http.Request) error { - req.Header.Add("Authorization", "Bearer "+tokenManager.getBearerToken()) - req.Header.Add("org", apidInfo.ClusterID) // todo: this is strange.. is it needed? - return nil -} - func addHeaders(req *http.Request) { req.Header.Add("Authorization", "Bearer "+ tokenManager.getBearerToken()) req.Header.Set("apid_instance_id", apidInfo.InstanceID)
diff --git a/snapshot.go b/snapshot.go index ae667bf..5a1c576 100644 --- a/snapshot.go +++ b/snapshot.go
@@ -140,12 +140,15 @@ log.Infof("Snapshot Download: %s", uri) client := &http.Client{ - CheckRedirect: Redirect, + CheckRedirect: func(req *http.Request, _ []*http.Request) error { + req.Header.Set("Authorization", "Bearer "+tokenManager.getBearerToken()) + return nil + }, Timeout: httpTimeout, } //pollWithBackoff only accepts function that accept a single quit channel - //to accomadate functions which need more parameters, wrap them in closures + //to accommodate functions which need more parameters, wrap them in closures attemptDownload := getAttemptDownloadClosure(client, snapshot, uri) pollWithBackoff(quitPolling, attemptDownload, handleSnapshotServerError)