Browse Source

one more 'listening' race condition

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
38f117cb6d
  1. 5
      test/simple/test-http-upgrade-client.js

5
test/simple/test-http-upgrade-client.js

@ -26,9 +26,11 @@ var srv = net.createServer(function(c) {
c.end(); c.end();
}); });
}); });
srv.listen(common.PORT, '127.0.0.1');
var gotUpgrade = false; var gotUpgrade = false;
srv.listen(common.PORT, '127.0.0.1', function () {
var hc = http.createClient(common.PORT, '127.0.0.1'); var hc = http.createClient(common.PORT, '127.0.0.1');
hc.addListener('upgrade', function(res, socket, upgradeHead) { hc.addListener('upgrade', function(res, socket, upgradeHead) {
// XXX: This test isn't fantastic, as it assumes that the entire response // XXX: This test isn't fantastic, as it assumes that the entire response
@ -48,6 +50,7 @@ hc.addListener('upgrade', function(res, socket, upgradeHead) {
gotUpgrade = true; gotUpgrade = true;
}); });
hc.request('GET', '/').end(); hc.request('GET', '/').end();
});
process.addListener('exit', function() { process.addListener('exit', function() {
assert.ok(gotUpgrade); assert.ok(gotUpgrade);

Loading…
Cancel
Save