node/test/parallel/test-http-client-finished.js
Matteo Collina 9f873b3a65 Revert "stream: make finished call the callback if the stream is closed"
This reverts commit b03845b937.

PR-URL: https://github.com/nodejs/node/pull/29717
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
2019-10-10 10:34:12 +02:00

28 lines
553 B
JavaScript

'use strict';
const common = require('../common');
const http = require('http');
const { finished } = require('stream');
{
// Test abort before finished.
const server = http.createServer(function(req, res) {
res.write('asd');
});
server.listen(0, common.mustCall(function() {
http.request({
port: this.address().port
})
.on('response', (res) => {
res.on('readable', () => {
res.destroy();
});
finished(res, common.mustCall(() => {
server.close();
}));
})
.end();
}));
}