mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
14 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var http = require('http');
|
||
|
var net = require('net');
|
||
15 years ago
|
|
||
14 years ago
|
var server = http.createServer(function(req, res) {
|
||
15 years ago
|
common.error('got req');
|
||
14 years ago
|
throw new Error('This shouldn\'t happen.');
|
||
15 years ago
|
});
|
||
|
|
||
13 years ago
|
server.on('upgrade', function(req, socket, upgradeHead) {
|
||
15 years ago
|
common.error('got upgrade event');
|
||
15 years ago
|
// test that throwing an error from upgrade gets
|
||
15 years ago
|
// is uncaught
|
||
15 years ago
|
throw new Error('upgrade error');
|
||
|
});
|
||
|
|
||
14 years ago
|
var gotError = false;
|
||
15 years ago
|
|
||
13 years ago
|
process.on('uncaughtException', function(e) {
|
||
14 years ago
|
common.error('got \'clientError\' event');
|
||
15 years ago
|
assert.equal('upgrade error', e.message);
|
||
|
gotError = true;
|
||
15 years ago
|
process.exit(0);
|
||
15 years ago
|
});
|
||
|
|
||
15 years ago
|
|
||
14 years ago
|
server.listen(common.PORT, function() {
|
||
15 years ago
|
var c = net.createConnection(common.PORT);
|
||
15 years ago
|
|
||
13 years ago
|
c.on('connect', function() {
|
||
15 years ago
|
common.error('client wrote message');
|
||
14 years ago
|
c.write('GET /blah HTTP/1.1\r\n' +
|
||
|
'Upgrade: WebSocket\r\n' +
|
||
|
'Connection: Upgrade\r\n' +
|
||
|
'\r\n\r\nhello world');
|
||
15 years ago
|
});
|
||
|
|
||
13 years ago
|
c.on('end', function() {
|
||
15 years ago
|
c.end();
|
||
|
});
|
||
|
|
||
13 years ago
|
c.on('close', function() {
|
||
15 years ago
|
common.error('client close');
|
||
15 years ago
|
server.close();
|
||
|
});
|
||
|
});
|
||
|
|
||
13 years ago
|
process.on('exit', function() {
|
||
15 years ago
|
assert.ok(gotError);
|
||
|
});
|