mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-12 16:38:12 -05:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
331e6e85b9 | ||
|
|
f2df40aa02 | ||
|
|
36ecd49ad2 | ||
|
|
aef5027640 | ||
|
|
4933cf1a9e | ||
|
|
c425724bd2 | ||
|
|
0b9bc61ff1 | ||
|
|
3bab44506b | ||
|
|
aeac79faa9 | ||
|
|
903f7ec9ff |
18
History.md
18
History.md
@@ -1,5 +1,19 @@
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
0.7.2 / 2011-06-22
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
* Make sure to write a packet (of type `noop`) when closing a poll.
|
||||
This solves a problem with cross-domain requests being flagged as aborted and
|
||||
reconnection being triggered.
|
||||
* Added `noop` message type.
|
||||
|
||||
0.7.1 / 2011-06-21
|
||||
==================
|
||||
|
||||
* Fixed cross-domain XHR.
|
||||
* Added CORS test to xhr-polling suite.
|
||||
|
||||
0.7.0 / 2010-06-21
|
||||
==================
|
||||
|
||||
* http://socket.io/announcement.html
|
||||
|
||||
@@ -22,6 +22,7 @@ var packets = exports.packets = [
|
||||
, 'event'
|
||||
, 'ack'
|
||||
, 'error'
|
||||
, 'noop'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ var http = require('http')
|
||||
* Version.
|
||||
*/
|
||||
|
||||
exports.version = '0.7.0';
|
||||
exports.version = '0.7.2';
|
||||
|
||||
/**
|
||||
* Supported protocol version.
|
||||
|
||||
@@ -56,7 +56,7 @@ HTTPPolling.prototype.handleRequest = function (req) {
|
||||
var self = this;
|
||||
|
||||
this.pollTimeout = setTimeout(function () {
|
||||
self.close();
|
||||
self.packet({ type: 'noop' });
|
||||
self.log.debug('polling closed due to exceeded duration');
|
||||
}, this.manager.get('polling duration') * 1000);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ HTTPTransport.prototype.handleRequest = function (req) {
|
||||
var buffer = ''
|
||||
, res = req.res
|
||||
, origin = req.headers.origin
|
||||
, headers = { 'Content-Length': 0 }
|
||||
, headers = { 'Content-Length': 1 }
|
||||
, self = this;
|
||||
|
||||
req.on('data', function (data) {
|
||||
@@ -66,8 +66,8 @@ HTTPTransport.prototype.handleRequest = function (req) {
|
||||
}
|
||||
}
|
||||
|
||||
res.writeHead(200);
|
||||
res.end('');
|
||||
res.writeHead(200, headers);
|
||||
res.end('1');
|
||||
} else {
|
||||
this.response = req.res;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "socket.io"
|
||||
, "version": "0.7.0"
|
||||
, "version": "0.7.2"
|
||||
, "description": "Realtime apps made cross-browser & easy with a WebSocket-like API"
|
||||
, "homepage": "http://socket.io"
|
||||
, "keywords": ["websocket", "socket", "realtime", "socket.io", "comet", "ajax"]
|
||||
@@ -15,7 +15,7 @@
|
||||
, "url": "https://github.com/LearnBoost/Socket.IO-node.git"
|
||||
}
|
||||
, "dependencies": {
|
||||
"socket.io-client": "0.7.0"
|
||||
"socket.io-client": "0.7.2"
|
||||
, "policyfile": ">= 0.0.3"
|
||||
}
|
||||
, "devDependencies": {
|
||||
|
||||
@@ -53,10 +53,10 @@ HTTPClient.prototype.request = function (path, opts, fn) {
|
||||
opts.host = 'localhost';
|
||||
opts.port = this.port;
|
||||
opts.path = path.replace(/{protocol}/g, io.protocol);
|
||||
opts.headers = {
|
||||
'Host': 'localhost'
|
||||
, 'Connection': 'keep-alive'
|
||||
};
|
||||
|
||||
opts.headers = opts.headers || {};
|
||||
opts.headers.Host = 'localhost';
|
||||
opts.headers.Connection = 'keep-alive';
|
||||
|
||||
var req = http.request(opts, function (res) {
|
||||
if (false === opts.buffer)
|
||||
|
||||
@@ -178,9 +178,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
// we rely on a small poll duration to close this request quickly
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, data) {
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
--total || finish();
|
||||
});
|
||||
});
|
||||
@@ -327,7 +328,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'disconnect' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -398,7 +399,7 @@ module.exports = {
|
||||
])
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -459,8 +460,9 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, data) {
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, msgs) {
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
tobi();
|
||||
|
||||
@@ -507,7 +509,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -588,21 +590,21 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/jsonp-polling/' + sid
|
||||
, parser.encodePacket({ type: 'disconnect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/jsonp-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', data: 'ferret' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -649,16 +651,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, data) {
|
||||
cl.get('/socket.io/{protocol}/jsonp-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/jsonp-polling/' + sid
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -667,7 +670,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -723,7 +726,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'message', data: '' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -732,14 +735,14 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/jsonp-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', endpoint: '/a', data: 'a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -750,14 +753,14 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/jsonp-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', endpoint: '/b', data: 'b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,9 +114,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
// we rely on a small poll duration to close this request quickly
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
--total || finish();
|
||||
});
|
||||
});
|
||||
@@ -263,7 +264,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'disconnect' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -334,7 +335,7 @@ module.exports = {
|
||||
])
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -395,8 +396,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
tobi();
|
||||
|
||||
@@ -443,7 +446,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -524,21 +527,21 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'disconnect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', data: 'ferret' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -585,16 +588,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -603,7 +607,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -659,7 +663,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'message', data: '' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
|
||||
@@ -668,14 +672,14 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', endpoint: '/a', data: 'a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -686,14 +690,14 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'message', endpoint: '/b', data: 'b' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -724,9 +728,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.json.send(['a', 'b', 'c']);
|
||||
s.json.send({
|
||||
@@ -785,9 +790,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -795,8 +801,9 @@ module.exports = {
|
||||
type: 'json'
|
||||
, data: { tobi: 'rocks' }
|
||||
})
|
||||
, function (res) {
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.equal('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -804,8 +811,9 @@ module.exports = {
|
||||
type: 'json'
|
||||
, data: 5000
|
||||
})
|
||||
, function (res) {
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.equal('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -835,9 +843,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.emit('tobi is playing');
|
||||
|
||||
@@ -877,9 +886,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.emit('edwald', { woot: 'woot' }, [1, 2, 3]);
|
||||
|
||||
@@ -922,9 +932,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -932,8 +943,9 @@ module.exports = {
|
||||
type: 'event'
|
||||
, name: 'jane'
|
||||
})
|
||||
, function (res) {
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.equal('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -968,9 +980,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -979,8 +992,9 @@ module.exports = {
|
||||
, name: 'woot'
|
||||
, args: ['a', 2, [1, 2]]
|
||||
})
|
||||
, function (res) {
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.equal('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1008,15 +1022,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.volatile.send('woooot');
|
||||
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1043,15 +1059,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.volatile.json.send('woooot');
|
||||
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1078,15 +1096,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
s.volatile.emit('woooot');
|
||||
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1232,9 +1252,10 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1246,7 +1267,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1315,7 +1336,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1364,7 +1385,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1500,7 +1521,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1566,7 +1587,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1577,7 +1598,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1616,7 +1637,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1674,7 +1695,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1740,7 +1761,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1751,7 +1772,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1800,7 +1821,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/a' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -1812,7 +1833,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1850,7 +1871,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
s.volatile.send('woot');
|
||||
|
||||
@@ -1902,7 +1923,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
s.volatile.json.send(15);
|
||||
|
||||
@@ -1954,7 +1975,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
s.volatile.json.emit('woot');
|
||||
|
||||
@@ -2006,7 +2027,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2073,7 +2094,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2140,7 +2161,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/chrislee' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2211,7 +2232,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/tobi' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2223,7 +2244,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2286,7 +2307,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/tobi' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2299,7 +2320,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2362,7 +2383,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/tobi' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2376,7 +2397,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2438,7 +2459,7 @@ module.exports = {
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/woot' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2466,7 +2487,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2505,16 +2526,17 @@ module.exports = {
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, function (res, msgs) {
|
||||
res.statusCode.should.equal(200);
|
||||
msgs.should.have.length(1);
|
||||
msgs[0].should.eql({ type: 'noop', endpoint: '' });
|
||||
|
||||
cl.post(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
, parser.encodePacket({ type: 'connect', endpoint: '/rapture' })
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
|
||||
cl.get(
|
||||
'/socket.io/{protocol}/xhr-polling/' + sid
|
||||
@@ -2545,7 +2567,7 @@ module.exports = {
|
||||
})
|
||||
, function (res, data) {
|
||||
res.statusCode.should.eql(200);
|
||||
data.should.eql('');
|
||||
data.should.eql('1');
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2554,6 +2576,65 @@ module.exports = {
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
'test CORS': function (done) {
|
||||
var cl = client(++ports)
|
||||
, io = create(cl)
|
||||
, messaged = false;
|
||||
|
||||
io.configure(function () {
|
||||
io.set('polling duration', .05);
|
||||
io.set('close timeout', .05);
|
||||
});
|
||||
|
||||
io.sockets.on('connection', function (socket) {
|
||||
socket.send('woot');
|
||||
|
||||
socket.on('message', function (msg) {
|
||||
msg.should.equal('woot');
|
||||
messaged = true;
|
||||
});
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
cl.end();
|
||||
io.server.close();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
cl.handshake(function (sid) {
|
||||
cl.get('/socket.io/{protocol}/xhr-polling/' + sid, {
|
||||
headers: {
|
||||
Origin: 'http://localhost:3500'
|
||||
}
|
||||
}, function (res, packs) {
|
||||
var headers = res.headers;
|
||||
|
||||
headers['access-control-allow-origin'].should.equal('*');
|
||||
should.strictEqual(headers['access-control-allow-credentials'], undefined);
|
||||
|
||||
packs.should.have.length(1);
|
||||
packs[0].type.should.eql('message');
|
||||
packs[0].data.should.eql('woot');
|
||||
|
||||
cl.post('/socket.io/{protocol}/xhr-polling/' + sid, parser.encodePacket({
|
||||
type: 'message'
|
||||
, data: 'woot'
|
||||
}), {
|
||||
headers: {
|
||||
Origin: 'http://localhost:3500'
|
||||
, Cookie: 'woot=woot'
|
||||
}
|
||||
}, function (res, data) {
|
||||
var headers = res.headers;
|
||||
headers['access-control-allow-origin'].should.equal('*');
|
||||
headers['access-control-allow-credentials'].should.equal('true');
|
||||
|
||||
data.should.equal('1');
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user