From 1fd860faafa320c4fb0c0445d5843c81dedbda0f Mon Sep 17 00:00:00 2001 From: Yuval Rimar Date: Wed, 4 Jul 2012 11:29:49 +0300 Subject: [PATCH] prevent crash when 302 is returned without location header --- lib/node-http-proxy/http-proxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index 3306defcc..924ef0e23 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -235,10 +235,10 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { } if ((response.statusCode === 301) || (response.statusCode === 302)) { - if (self.source.https && !self.target.https) { + if (self.source.https && !self.target.https && response.headers.location != null) { response.headers.location = response.headers.location.replace(/^http\:/, 'https:'); } - if (self.target.https && !self.source.https) { + if (self.target.https && !self.source.https && response.headers.location != null) { response.headers.location = response.headers.location.replace(/^https\:/, 'http:'); } }