mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
use default HTTP client to download blob from redirect URL
This commit is contained in:
parent
d98ca18787
commit
996452a5ed
1 changed files with 7 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue