From 98d7bd9fced6316a1ada82ae23ef9b098a3bf4f8 Mon Sep 17 00:00:00 2001
From: Marcus Weiner <marcus.weiner@gmail.com>
Date: Wed, 25 Apr 2018 23:13:24 +0200
Subject: [PATCH] fix: skip to next source on 404 response

Whenever there is more than one source configured, the storage should be able to test for existence on each source and resolve to the first that responds sucessfully. This commit will only pass the data of the HTTP request if it resolves with a HTTP status code starting with 2
---
 src/WebHelper.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/WebHelper.js b/src/WebHelper.js
index 303510e..d626606 100644
--- a/src/WebHelper.js
+++ b/src/WebHelper.js
@@ -70,7 +70,7 @@ class WebHelper extends Helper {
 
                     nets({url: url}, (err, resp, body) => {
                         // body is a Buffer
-                        if (err) {
+                        if (err || Math.floor(resp.statusCode / 100) !== 2) {
                             tryNextSource();
                         } else {
                             asset.setData(body, dataFormat);