1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) { common.skip('missing crypto'); } 4const assert = require('assert'); 5const http2 = require('http2'); 6 7const server = http2.createServer(common.mustCall((req, res) => { 8 const hwm = req.socket.writableHighWaterMark; 9 assert.strictEqual(res.writableHighWaterMark, hwm); 10 assert.strictEqual(res.writableLength, 0); 11 res.write(''); 12 const len = res.writableLength; 13 res.write('asd'); 14 assert.strictEqual(res.writableLength, len + 3); 15 res.end(); 16 res.on('finish', common.mustCall(() => { 17 assert.strictEqual(res.writableLength, 0); 18 assert.ok(res.writableFinished, 'writableFinished is not truthy'); 19 server.close(); 20 })); 21})); 22 23server.listen(0, common.mustCall(() => { 24 const client = http2.connect(`http://localhost:${server.address().port}`); 25 const request = client.request(); 26 request.on('data', common.mustCall()); 27 request.on('end', common.mustCall(() => { 28 client.close(); 29 })); 30})); 31