mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
server: remove buffering from handleSocket
This commit is contained in:
@@ -271,29 +271,16 @@ Server.prototype.onWebSocket = function(req, socket){
|
||||
|
||||
var policy = readFileSync(__dirname + '/transports/flashsocket.xml');
|
||||
|
||||
Server.prototype.handleSocket = function (socket) {
|
||||
var chunks = ''
|
||||
, buffer = false
|
||||
|
||||
socket.on('data', function onData (data) {
|
||||
if (!buffer && 60 == data[0]) {
|
||||
buffer = true;
|
||||
} else {
|
||||
socket.removeListener('data', onData);
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunks.length < 23) {
|
||||
chunks += data.toString('ascii');
|
||||
}
|
||||
|
||||
if (chunks.length >= 23) {
|
||||
if ('<policy-file-request/>\0' == chunks.substr(0, 23)) {
|
||||
Server.prototype.handleSocket = function(socket){
|
||||
socket.on('data', function onData(data){
|
||||
// no need for buffering as node will discard subsequent packets
|
||||
// since they constitute a malformed HTTP request
|
||||
if (60 == data[0] && 23 == data.length) {
|
||||
var str = data.slice(0, 23).toString();
|
||||
if ('<policy-file-request/>\0' == str) {
|
||||
socket.end(policy);
|
||||
} else {
|
||||
chunks = null;
|
||||
socket.removeListener('data', onData);
|
||||
}
|
||||
}
|
||||
socket.removeListener('data', onData);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user