mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [netutil] reject failed download responses (#388)
This commit is contained in:
1 parent
be9b167a9b
commit
f1db13387b
2 files changed
+43
No files matched your search
@@ -288,6 +288,9 @@ func DownloadFile(filepath string, url string) error {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
|
||||
return fmt.Errorf("download failed: %s", resp.Status)
|
||||
}
|
||||
|
||||
out, err := os.Create(filepath)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user