test: fix http-upgrade-agent
flakiness
It's not guaranteed that the socket data is received in the same chunk as the upgrade response. Listen for the `data` event to make sure all the data is received. PR-URL: https://github.com/nodejs/node/pull/4520 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
3a7f106b8c
commit
6018fa1f57
@ -46,9 +46,14 @@ srv.listen(common.PORT, '127.0.0.1', function() {
|
||||
req.end();
|
||||
|
||||
req.on('upgrade', function(res, socket, upgradeHead) {
|
||||
// XXX: This test isn't fantastic, as it assumes that the entire response
|
||||
// from the server will arrive in a single data callback
|
||||
assert.equal(upgradeHead, 'nurtzo');
|
||||
var recvData = upgradeHead;
|
||||
socket.on('data', function(d) {
|
||||
recvData += d;
|
||||
});
|
||||
|
||||
socket.on('close', common.mustCall(function() {
|
||||
assert.equal(recvData, 'nurtzo');
|
||||
}));
|
||||
|
||||
console.log(res.headers);
|
||||
var expectedHeaders = { 'hello': 'world',
|
||||
|
Loading…
x
Reference in New Issue
Block a user