Invalid transport test completed

This commit is contained in:
Guillermo Rauch
2010-10-28 23:14:38 -03:00
parent 71c99bfb87
commit bdbb419f95
2 changed files with 9 additions and 23 deletions

View File

@@ -165,10 +165,6 @@ Listener.prototype._onClientDisconnect = function(client){
};
Listener.prototype._onConnection = function(transport, req, res, httpUpgrade, head){
if (this.options.transports.indexOf(transport) === -1 || (httpUpgrade && !transports[transport].httpUpgrade)){
req.connection.end();
return this.options.log('Illegal transport "'+ transport +'"');
}
this.options.log('Initializing client with transport "'+ transport +'"');
new transports[transport](this, req, res, this.options.transportOptions[transport], head);
};

View File

@@ -6,8 +6,8 @@ var http = require('http')
, Listener = io.Listener
, WebSocket = require('./../support/node-websocket-client/lib/websocket').WebSocket;
function server(){
return http.createServer(function(){});
function server(callback){
return http.createServer(callback || function(){});
};
function socket(server, options){
@@ -139,24 +139,14 @@ module.exports = {
});
},
'test connecting to an invalid transport': function(){
var _server = server()
, _socket = socket(_server, { log: require('sys').log });
'test connecting to an invalid transport': function(assert){
var _server = server(function(req, res){
res.writeHead(200);
res.end(req.url == '/socket.io/inexistent' ? 'All cool' : '');
})
, _socket = socket(_server);
listen(_server, function(){
var _client = net.createConnection(_server._port)
, noData = true;
_client.on('connect', function(){
_client.write("GET /socket.io/inexistent HTTP/1.1\r\n\r\n");
_client.on('data', function(){
noData = false;
});
_client.on('end', function(){
assert.ok(noData);
_client.end();
});
});
});
assert.response(_server, { url: '/socket.io/inexistent' }, { body: 'All cool' });
}
};