Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 38f117c

Browse files
committed
one more 'listening' race condition
1 parent 44234e9 commit 38f117c

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

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

+22-19
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,31 @@ var srv = net.createServer(function(c) {
2626
c.end();
2727
});
2828
});
29-
srv.listen(common.PORT, '127.0.0.1');
3029

3130
var gotUpgrade = false;
32-
var hc = http.createClient(common.PORT, '127.0.0.1');
33-
hc.addListener('upgrade', function(res, socket, upgradeHead) {
34-
// XXX: This test isn't fantastic, as it assumes that the entire response
35-
// from the server will arrive in a single data callback
36-
assert.equal(upgradeHead, 'nurtzo');
37-
38-
console.log(res.headers);
39-
var expectedHeaders = { "hello": "world"
40-
, "connection": "upgrade"
41-
, "upgrade": "websocket"
42-
};
43-
assert.deepEqual(expectedHeaders, res.headers);
44-
45-
socket.end();
46-
srv.close();
47-
48-
gotUpgrade = true;
31+
32+
srv.listen(common.PORT, '127.0.0.1', function () {
33+
34+
var hc = http.createClient(common.PORT, '127.0.0.1');
35+
hc.addListener('upgrade', function(res, socket, upgradeHead) {
36+
// XXX: This test isn't fantastic, as it assumes that the entire response
37+
// from the server will arrive in a single data callback
38+
assert.equal(upgradeHead, 'nurtzo');
39+
40+
console.log(res.headers);
41+
var expectedHeaders = { "hello": "world"
42+
, "connection": "upgrade"
43+
, "upgrade": "websocket"
44+
};
45+
assert.deepEqual(expectedHeaders, res.headers);
46+
47+
socket.end();
48+
srv.close();
49+
50+
gotUpgrade = true;
51+
});
52+
hc.request('GET', '/').end();
4953
});
50-
hc.request('GET', '/').end();
5154

5255
process.addListener('exit', function() {
5356
assert.ok(gotUpgrade);

0 commit comments

Comments
 (0)