From 013cb2e0c2089848ff0a0164751dc9760c838a8a Mon Sep 17 00:00:00 2001 From: indexzero Date: Sat, 9 Mar 2013 00:28:50 -0500 Subject: [PATCH] [fix] Ensure `response.headers.location` is defined. Fixes #276. --- lib/node-http-proxy/http-proxy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index a26a68c..7e97041 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -247,7 +247,8 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { delete response.headers['transfer-encoding']; } - if ((response.statusCode === 301) || (response.statusCode === 302)) { + if ((response.statusCode === 301) || (response.statusCode === 302) + && typeof response.headers.location !== 'undefined') { if (self.source.https && !self.target.https) { response.headers.location = response.headers.location.replace(/^http\:/, 'https:'); }