Skip to content

Commit

Permalink
test: simplify test-http-write-callbacks.js
Browse files Browse the repository at this point in the history
PR-URL: #42628
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
tniessen authored and juanarbol committed May 31, 2022
1 parent 9caffa1 commit 50e701d
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions test/parallel/test-http-write-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');

const http = require('http');
Expand Down Expand Up @@ -53,15 +53,13 @@ server.on('checkContinue', (req, res) => {
res.writeContinue(() => {
// Continue has been written
req.on('end', () => {
res.write('asdf', (er) => {
assert.ifError(er);
res.write('foo', 'ascii', (er) => {
assert.ifError(er);
res.end(Buffer.from('bar'), 'buffer', (er) => {
res.write('asdf', common.mustSucceed(() => {
res.write('foo', 'ascii', common.mustSucceed(() => {
res.end(Buffer.from('bar'), 'buffer', common.mustSucceed(() => {
serverEndCb = true;
});
});
});
}));
}));
}));
});
});

Expand All @@ -79,16 +77,13 @@ server.listen(0, function() {
});
req.on('continue', () => {
// ok, good to go.
req.write('YmF6', 'base64', (er) => {
assert.ifError(er);
req.write(Buffer.from('quux'), (er) => {
assert.ifError(er);
req.end('626c657267', 'hex', (er) => {
assert.ifError(er);
req.write('YmF6', 'base64', common.mustSucceed(() => {
req.write(Buffer.from('quux'), common.mustSucceed(() => {
req.end('626c657267', 'hex', common.mustSucceed(() => {
clientEndCb = true;
});
});
});
}));
}));
}));
});
req.on('response', (res) => {
// This should not come until after the end is flushed out
Expand Down

0 comments on commit 50e701d

Please sign in to comment.