faye-websocket
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -58,6 +58,5 @@ // API and protocol references: | ||
}); | ||
this._stream.addListener('close', function() { | ||
self.close(1006, '', false); | ||
['close', 'end', 'error'].forEach(function(event) { | ||
self._stream.addListener(event, function() { self.close(1006, '', false) }); | ||
}); | ||
this._stream.addListener('error', function() {}); | ||
}; | ||
@@ -64,0 +63,0 @@ |
@@ -19,11 +19,8 @@ var Draft75Parser = function(webSocket, stream) { | ||
try { | ||
stream.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n'); | ||
stream.write('Upgrade: WebSocket\r\n'); | ||
stream.write('Connection: Upgrade\r\n'); | ||
stream.write('WebSocket-Origin: ' + this._socket.request.headers.origin + '\r\n'); | ||
stream.write('WebSocket-Location: ' + this._socket.url + '\r\n\r\n'); | ||
} catch (e) { | ||
// socket closed while writing | ||
// no handshake sent; client will stop using WebSocket | ||
} | ||
stream.write( 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + | ||
'Upgrade: WebSocket\r\n' + | ||
'Connection: Upgrade\r\n' + | ||
'WebSocket-Origin: ' + this._socket.request.headers.origin + '\r\n' + | ||
'WebSocket-Location: ' + this._socket.url + '\r\n\r\n'); | ||
} catch (e) {} | ||
}, | ||
@@ -30,0 +27,0 @@ |
@@ -31,2 +31,21 @@ var crypto = require('crypto'), | ||
var request = this._socket.request, | ||
stream = this._stream; | ||
try { | ||
stream.write( 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + | ||
'Upgrade: WebSocket\r\n' + | ||
'Connection: Upgrade\r\n' + | ||
'Sec-WebSocket-Origin: ' + request.headers.origin + '\r\n' + | ||
'Sec-WebSocket-Location: ' + this._socket.url + '\r\n\r\n', | ||
'binary'); | ||
} catch (e) {} | ||
this.handshakeSignature(head); | ||
}; | ||
Draft76Parser.prototype.handshakeSignature = function(head) { | ||
if (head.length === 0) return; | ||
this._handshakeComplete = true; | ||
var request = this._socket.request, | ||
stream = this._stream, | ||
@@ -47,15 +66,14 @@ | ||
try { | ||
stream.write('HTTP/1.1 101 Web Socket Protocol Handshake\r\n', 'binary'); | ||
stream.write('Upgrade: WebSocket\r\n', 'binary'); | ||
stream.write('Connection: Upgrade\r\n', 'binary'); | ||
stream.write('Sec-WebSocket-Origin: ' + request.headers.origin + '\r\n', 'binary'); | ||
stream.write('Sec-WebSocket-Location: ' + this._socket.url + '\r\n\r\n', 'binary'); | ||
stream.write(MD5.digest('binary'), 'binary'); | ||
} catch (e) { | ||
// socket closed while writing | ||
// no handshake sent; client will stop using WebSocket | ||
} | ||
} catch (e) {}; | ||
}; | ||
Draft76Parser.prototype.parse = function(data) { | ||
if (this._handshakeComplete) | ||
return Draft75Parser.prototype.parse.call(this, data); | ||
this.handshakeSignature(data); | ||
}; | ||
module.exports = Draft76Parser; | ||
@@ -46,9 +46,8 @@ var crypto = require('crypto'); | ||
try { | ||
stream.write('GET ' + u.pathname + (u.search || '') + ' HTTP/1.1\r\n'); | ||
stream.write('Host: ' + u.hostname + (u.port ? ':' + u.port : '') + '\r\n'); | ||
stream.write('Upgrade: websocket\r\n'); | ||
stream.write('Connection: Upgrade\r\n'); | ||
stream.write('Sec-WebSocket-Key: ' + this._key + '\r\n'); | ||
stream.write('Sec-WebSocket-Version: 8\r\n'); | ||
stream.write('\r\n'); | ||
stream.write( 'GET ' + u.pathname + (u.search || '') + ' HTTP/1.1\r\n' + | ||
'Host: ' + u.hostname + (u.port ? ':' + u.port : '') + '\r\n' + | ||
'Upgrade: websocket\r\n' + | ||
'Connection: Upgrade\r\n' + | ||
'Sec-WebSocket-Key: ' + this._key + '\r\n' + | ||
'Sec-WebSocket-Version: 8\r\n\r\n'); | ||
} catch (e) {} | ||
@@ -140,10 +139,7 @@ }; | ||
try { | ||
stream.write('HTTP/1.1 101 Switching Protocols\r\n'); | ||
stream.write('Upgrade: websocket\r\n'); | ||
stream.write('Connection: Upgrade\r\n'); | ||
stream.write('Sec-WebSocket-Accept: ' + accept + '\r\n\r\n'); | ||
} catch (e) { | ||
// socket closed while writing | ||
// no handshake sent; client will stop using WebSocket | ||
} | ||
stream.write( 'HTTP/1.1 101 Switching Protocols\r\n' + | ||
'Upgrade: websocket\r\n' + | ||
'Connection: Upgrade\r\n' + | ||
'Sec-WebSocket-Accept: ' + accept + '\r\n\r\n'); | ||
} catch (e) {} | ||
}, | ||
@@ -150,0 +146,0 @@ |
@@ -7,3 +7,3 @@ { "name" : "faye-websocket" | ||
, "version" : "0.1.1" | ||
, "version" : "0.1.2" | ||
, "engines" : {"node": ">=0.4.0"} | ||
@@ -10,0 +10,0 @@ , "main" : "./lib/faye/websocket" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
739103
34
1054
9