Skip to content

Commit

Permalink
worker: verify download status code
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-M authored and jzelinskie committed Feb 24, 2016
1 parent f0816d2 commit c2605e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions worker/detectors/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func DetectData(path string, format string, toExtract []string, maxFileSize int6
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
r, err := http.Get(path)
if err != nil {
log.Warningf("could not download layer: %s", err)
return nil, cerrors.ErrCouldNotDownload
}
if math.Floor(float64(r.StatusCode/100)) != 2 {
log.Warningf("could not download layer: got status code %d, expected 2XX", r.StatusCode)
return nil, cerrors.ErrCouldNotDownload
}
if err != nil {
Expand Down

0 comments on commit c2605e0

Please sign in to comment.