only read response.statusCode if response is available

This commit is contained in:
jomo 2015-02-20 19:44:28 +01:00
parent ebd42a1e0f
commit e093371955

View File

@ -54,9 +54,11 @@ exp.get_from_options = function(rid, url, options, callback) {
encoding: (options.encoding || null), encoding: (options.encoding || null),
}, function(error, response, body) { }, function(error, response, body) {
// log url + code + description // log url + code + description
var code = response.statusCode; var code = response && response.statusCode;
logfunc = code && code < 405 ? logging.log : logging.warn; if (!error) {
logfunc(rid + url + " " + code + " " + http_code[code]); var logfunc = code && code < 405 ? logging.log : logging.warn;
logfunc(rid + url + " " + code + " " + http_code[code]);
}
// 200 or 301 depending on content type // 200 or 301 depending on content type
if (!error && (code === 200 || code === 301)) { if (!error && (code === 200 || code === 301)) {