Skip to content

Commit

Permalink
Report error for download when http GET returns non OK status
Browse files Browse the repository at this point in the history
  • Loading branch information
aajith-arista committed Jan 2, 2024
1 parent 51094da commit 42dedb3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions impl/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ func download(srcURL string, targetDir string,
return "", GetErr
}

if response.StatusCode != http.StatusOK {
return "", fmt.Errorf("%sutil.download: GET %s returned %d %s",
errPrefix, srcURL, response.StatusCode,
http.StatusText(response.StatusCode))

}

defer response.Body.Close()
_, ioErr := io.Copy(file, response.Body)
if ioErr != nil {
Expand Down

0 comments on commit 42dedb3

Please sign in to comment.