Fix #95 Don't look on req.connection if it's not set.

This commit is contained in:
isaacs 2011-08-28 13:41:05 -07:00
parent 1389b706b5
commit 62201a0917

View File

@ -428,7 +428,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
// * `x-forwarded-proto`: Protocol of the original request // * `x-forwarded-proto`: Protocol of the original request
// * `x-forwarded-port`: Port of the original request. // * `x-forwarded-port`: Port of the original request.
// //
if (options.enableXForwarded === true) { if (options.enableXForwarded === true && req.connection) {
req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress; req.headers['x-forwarded-for'] = req.connection.remoteAddress || req.connection.socket.remoteAddress;
req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort; req.headers['x-forwarded-port'] = req.connection.remotePort || req.connection.socket.remotePort;
req.headers['x-forwarded-proto'] = res.connection.pair ? 'https' : 'http'; req.headers['x-forwarded-proto'] = res.connection.pair ? 'https' : 'http';