2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-07-15 15:43:24 -04:00
|
|
|
const common = require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
2014-09-22 17:21:40 -07:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = http.Server(common.mustCall(function(req, res) {
|
2016-07-15 15:43:24 -04:00
|
|
|
res.on('error', common.mustCall(function onResError(err) {
|
|
|
|
assert.strictEqual(err.message, 'write after end');
|
|
|
|
}));
|
2014-09-22 17:21:40 -07:00
|
|
|
|
|
|
|
res.write('This should write.');
|
|
|
|
res.end();
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const r = res.write('This should raise an error.');
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(r, true, 'write after end should return true');
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2014-09-22 17:21:40 -07:00
|
|
|
|
2016-05-29 03:06:56 -04:00
|
|
|
server.listen(0, function() {
|
|
|
|
http.get({port: this.address().port}, function(res) {
|
2014-09-22 17:21:40 -07:00
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
});
|