From 3601b4442924241b18a2960411bc29632e32a1af Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 3 Nov 2016 14:17:23 +0000 Subject: [PATCH 1/2] Fix loading with no config from HTTP --- src/vector/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/index.js b/src/vector/index.js index 9454e6702e..c8093a8d98 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -183,7 +183,7 @@ function getConfig() { // we don't get 404s from file: URIs so this is the // only way we can not fail if the file doesn't exist // when loading from a file:// URI. - if (( err && err.response.status == 404) || body == '') { + if (( response && response.status == 404) || body == '') { deferred.resolve({}); } deferred.reject({err: err, response: response}); From cfe63fa274e77a52549222135862f5461fcfa407 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 3 Nov 2016 14:43:10 +0000 Subject: [PATCH 2/2] Better support no-config when loading from file We should still error if given a 5xx with an empty body. --- src/vector/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index c8093a8d98..9c9d48fae4 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -179,12 +179,15 @@ function getConfig() { if (err || response.status < 200 || response.status >= 300) { // Lack of a config isn't an error, we should // just use the defaults. - // Also treat a blank config as no config because - // we don't get 404s from file: URIs so this is the - // only way we can not fail if the file doesn't exist - // when loading from a file:// URI. - if (( response && response.status == 404) || body == '') { - deferred.resolve({}); + // Also treat a blank config as no config, assuming + // the status code is 0, because we don't get 404s + // from file: URIs so this is the only way we can + // not fail if the file doesn't exist when loading + // from a file:// URI. + if (response) { + if (response.status == 404 || (response.status == 0 && body == '')) { + deferred.resolve({}); + } } deferred.reject({err: err, response: response}); return;