Skip to content

Commit

Permalink
[minor] Style compliance. Fixes #402.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Apr 21, 2013
1 parent 985025c commit 59b71c0
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/node-http-proxy/http-proxy.js
Expand Up @@ -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'.
//
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down

1 comment on commit 59b71c0

@borismus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this fix anything? This is an entirely stylistic change as far as I can tell, and I'm still unable to proxy websockets as per #402.

Please sign in to comment.