From 996452a5edef7499b69ee0ded5a01416463c5fe2 Mon Sep 17 00:00:00 2001 From: rhysd Date: Fri, 19 Jan 2018 17:00:30 +0900 Subject: [PATCH] use default HTTP client to download blob from redirect URL --- selfupdate/update.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/selfupdate/update.go b/selfupdate/update.go index c889cba..b30447d 100644 --- a/selfupdate/update.go +++ b/selfupdate/update.go @@ -35,13 +35,18 @@ func (up *Updater) downloadDirectlyFromURL(assetURL string) (io.ReadCloser, erro } req.Header.Add("Accept", "application/octet-stream") - res, err := up.httpClient.Do(req) + req = req.WithContext(up.apiCtx) + + // OAuth HTTP client is not available to download blob from URL when the URL is a redirect URL + // returned from GitHub Releases API (response status 400). + // Use default HTTP client instead. + res, err := http.DefaultClient.Do(req) if err != nil { return nil, fmt.Errorf("Failed to download a release file from %s: %s", assetURL, err) } if res.StatusCode != 200 { - return nil, fmt.Errorf("Failed to download a release file from %s", assetURL) + return nil, fmt.Errorf("Failed to download a release file from %s: Not successfull status %d", assetURL, res.StatusCode) } return res.Body, nil