1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const http = require('http'); 5 6// Verify that after calling end() on an `OutgoingMessage` (or a type that 7// inherits from `OutgoingMessage`), its `writable` property is not set to false 8 9const server = http.createServer(common.mustCall(function(req, res) { 10 assert.strictEqual(res.writable, true); 11 assert.strictEqual(res.finished, false); 12 assert.strictEqual(res.writableEnded, false); 13 res.end(); 14 15 // res.writable is set to false after it has finished sending 16 // Ref: https://github.com/nodejs/node/issues/15029 17 assert.strictEqual(res.writable, true); 18 assert.strictEqual(res.finished, true); 19 assert.strictEqual(res.writableEnded, true); 20 21 server.close(); 22})); 23 24server.listen(0); 25 26server.on('listening', common.mustCall(function() { 27 const clientRequest = http.request({ 28 port: server.address().port, 29 method: 'GET', 30 path: '/' 31 }); 32 33 assert.strictEqual(clientRequest.writable, true); 34 clientRequest.end(); 35 36 // Writable is still true when close 37 // THIS IS LEGACY, we cannot change it 38 // unless we break error detection 39 assert.strictEqual(clientRequest.writable, true); 40})); 41