From 0b263704a90551c78da60303d7b3b42d471de69a Mon Sep 17 00:00:00 2001 From: Gustavo Ajzenman Date: Sat, 17 May 2014 19:12:40 -0300 Subject: [PATCH] Check if location was not sent in redirect header --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 586b7a8..a110d96 100644 --- a/index.js +++ b/index.js @@ -41,6 +41,11 @@ function direct(subquest, maxRedirects) { res.url = opts.uri; if (isRedirect(res.statusCode)) { remainingRedirects--; + + if (res.headers.location === undefined) { + return rs.emit('error', new Error('The response was redirected but received an empty Location')); + } + rs.emit('redirect', res); opts.uri = res.headers.location; return doRequest();