Futher aligns OutgoingMessage with stream.Writable. In particular re-uses the construct/destroy logic from streams. Due to a lot of subtle assumptions this PR unfortunately touches a lot of different parts. PR-URL: https://github.com/nodejs/node/pull/36816 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
37 lines
997 B
JavaScript
37 lines
997 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) {
|
|
res.end('testing ended state', common.mustCall());
|
|
assert.strictEqual(res.writableCorked, 0);
|
|
res.end(common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END');
|
|
}));
|
|
res.end('end', common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END');
|
|
}));
|
|
res.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_WRITE_AFTER_END');
|
|
}));
|
|
res.on('close', common.mustCall(() => {
|
|
res.end(common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED');
|
|
server.close();
|
|
}));
|
|
}));
|
|
}));
|
|
|
|
server.listen(0);
|
|
|
|
server.on('listening', common.mustCall(function() {
|
|
http
|
|
.request({
|
|
port: server.address().port,
|
|
method: 'GET',
|
|
path: '/'
|
|
})
|
|
.end();
|
|
}));
|