From c2605e0bf2db061ad56b70823a33724e2ec606d9 Mon Sep 17 00:00:00 2001 From: Quentin Machu Date: Fri, 12 Feb 2016 16:25:37 -0500 Subject: [PATCH] worker: verify download status code --- worker/detectors/data.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/worker/detectors/data.go b/worker/detectors/data.go index 011d067c..144f8125 100644 --- a/worker/detectors/data.go +++ b/worker/detectors/data.go @@ -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 {