[fix] Ensure response.headers.location is defined. Fixes #276.

This commit is contained in:
indexzero 2013-03-09 00:28:50 -05:00
parent deca7565c5
commit 013cb2e0c2

View File

@ -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:');
}