mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7032e59bb5
response.writableFinished is true if all data has been flushed to the underlying system. PR-URL: https://github.com/nodejs/node/pull/28681 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
33 lines
839 B
JavaScript
33 lines
839 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
|
assert.strictEqual(res.writableFinished, false);
|
|
res
|
|
.on('finish', common.mustCall(() => {
|
|
assert.strictEqual(res.writableFinished, true);
|
|
server.close();
|
|
}))
|
|
.end();
|
|
}));
|
|
|
|
server.listen(0);
|
|
|
|
server.on('listening', common.mustCall(function() {
|
|
const clientRequest = http.request({
|
|
port: server.address().port,
|
|
method: 'GET',
|
|
path: '/'
|
|
});
|
|
|
|
assert.strictEqual(clientRequest.writableFinished, false);
|
|
clientRequest
|
|
.on('finish', common.mustCall(() => {
|
|
assert.strictEqual(clientRequest.writableFinished, true);
|
|
}))
|
|
.end();
|
|
assert.strictEqual(clientRequest.writableFinished, false);
|
|
}));
|