diff --git a/lib/node-http-proxy/http-proxy.js b/lib/node-http-proxy/http-proxy.js index e44abaa..351b795 100644 --- a/lib/node-http-proxy/http-proxy.js +++ b/lib/node-http-proxy/http-proxy.js @@ -716,8 +716,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead, // In addition, it's important to note the closure scope here. Since // there is no mapping of the socket to the request bound to it. // - reverseProxy.on('upgrade', function ( res, remoteSocket, head) { - + reverseProxy.on('upgrade', function (res, remoteSocket, head) { // // Prepare handshake response 'headers' and 'statusCode'. // @@ -741,27 +740,22 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead, // reverseProxy.once('socket', function (revSocket) { revSocket.on('data', function handshake (data) { - // Set empty headers var headers = ''; // // If the handshake statusCode 101, concat headers. // - if(reverseProxy.handshake.statusCode && reverseProxy.handshake.statusCode == 101){ - + if (reverseProxy.handshake.statusCode && reverseProxy.handshake.statusCode == 101) { headers = [ - 'HTTP/1.1 101 Switching Protocols' - , 'Upgrade: websocket' - , 'Connection: Upgrade' - , 'Sec-WebSocket-Accept: ' + reverseProxy.handshake.headers['sec-websocket-accept'] + 'HTTP/1.1 101 Switching Protocols', + 'Upgrade: websocket', + 'Connection: Upgrade', + 'Sec-WebSocket-Accept: ' + reverseProxy.handshake.headers['sec-websocket-accept'] ]; headers = headers.concat('', '').join('\r\n'); - } - - // // Ok, kind of harmfull part of code. Socket.IO sends a hash @@ -793,7 +787,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, upgradeHead, // self.emit('websocket:handshake', req, socket, head, sdata, data); // add headers to the socket - socket.write(headers+sdata); + socket.write(headers + sdata); var flushed = socket.write(data); if (!flushed) { revSocket.pause();