mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Added websocket close event test
This commit is contained in:
parent
26537866b3
commit
8bff3ddc12
@ -336,6 +336,7 @@ describe('lib/http-proxy.js', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should proxy a socket.io stream', function (done) {
|
||||
var ports = { source: gen.port, proxy: gen.port },
|
||||
proxy = httpProxy.createProxyServer({
|
||||
@ -370,5 +371,36 @@ describe('lib/http-proxy.js', function() {
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('should emit close event when socket.io client disconnects', function (done) {
|
||||
var ports = { source: gen.port, proxy: gen.port };
|
||||
var proxy = httpProxy.createProxyServer({
|
||||
target: 'ws://127.0.0.1:' + ports.source,
|
||||
ws: true
|
||||
});
|
||||
proxyServer = proxy.listen(ports.proxy);
|
||||
var server = http.createServer();
|
||||
destiny = io.listen(server);
|
||||
|
||||
function startSocketIo() {
|
||||
var client = ioClient.connect('ws://127.0.0.1:' + ports.proxy);
|
||||
client.on('connect', function () {
|
||||
client.disconnect();
|
||||
});
|
||||
}
|
||||
|
||||
proxyServer.on('close', function() {
|
||||
proxyServer.close();
|
||||
server.close();
|
||||
done();
|
||||
});
|
||||
|
||||
server.listen(ports.source);
|
||||
server.on('listening', startSocketIo);
|
||||
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user