Skip to content

Commit

Permalink
Merge pull request #7611 from rifelpet/check-http-response-code
Browse files Browse the repository at this point in the history
Check the HTTP response code when downloading URLs
  • Loading branch information
k8s-ci-robot authored Sep 18, 2019
2 parents 0ae4613 + 7de96e1 commit d69c6ed
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions upup/pkg/fi/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func downloadURLAlways(url string, destPath string, dirMode os.FileMode) error {
if err != nil {
return fmt.Errorf("error doing HTTP fetch of %q: %v", url, err)
}
if response.StatusCode >= 400 {
return fmt.Errorf("error response from %q: HTTP %v", url, response.StatusCode)
}
defer response.Body.Close()

_, err = io.Copy(output, response.Body)
Expand Down

0 comments on commit d69c6ed

Please sign in to comment.