From 0933f1c598c1b62a75e040c3ed3ccb262612d3c9 Mon Sep 17 00:00:00 2001 From: Ramprasad Rajendran Date: Tue, 19 Jun 2012 12:00:24 +0530 Subject: [PATCH] Fix bug: x-forwarded-proto set incorrectly When routed via multiple proxies, x_forwarded_proto set as httphttps or wswss instead of http,https or ws,wss, since + operator seems to have a higher precedence than the terniary operator and the expression was getting evaluated to true always --- 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 e4f4ae6..3306def 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -148,7 +148,7 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) { } if (req.headers['x-forwarded-proto']){ - var protoToAppend = "," + (req.connection.pair) ? 'https' : 'http'; + var protoToAppend = "," + (req.connection.pair ? 'https' : 'http'); req.headers['x-forwarded-proto'] += protoToAppend; } else { @@ -415,7 +415,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer) } if (req.headers['x-forwarded-proto']){ - var protoToAppend = "," + (req.connection.pair) ? 'wss' : 'ws'; + var protoToAppend = "," + (req.connection.pair ? 'wss' : 'ws'); req.headers['x-forwarded-proto'] += protoToAppend; } else {