1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const http2 = require('http2'); 7 8// Check that writeHead, write and end do not crash in compatibility mode 9 10const server = http2.createServer(common.mustCall((req, res) => { 11 // Destroy the stream first 12 req.stream.destroy(); 13 14 res.writeHead(200); 15 res.write('hello '); 16 res.end('world'); 17})); 18 19server.listen(0, common.mustCall(() => { 20 const client = http2.connect(`http://localhost:${server.address().port}`); 21 22 const req = client.request(); 23 req.on('response', common.mustNotCall()); 24 req.on('close', common.mustCall((arg) => { 25 client.close(); 26 server.close(); 27 })); 28 req.resume(); 29})); 30