11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst http2 = require('http2'); 91cb0ef41Sopenharmony_ciconst net = require('net'); 101cb0ef41Sopenharmony_ciconst h2test = require('../common/http2'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst server = http2.createServer(); 131cb0ef41Sopenharmony_ciserver.on('stream', common.mustNotCall()); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst settings = new h2test.SettingsFrame(); 161cb0ef41Sopenharmony_ciconst settingsAck = new h2test.SettingsFrame(true); 171cb0ef41Sopenharmony_ciconst altsvc = new h2test.AltSvcFrame((1 << 14) + 1); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciserver.listen(0, () => { 201cb0ef41Sopenharmony_ci const client = net.connect(server.address().port, () => { 211cb0ef41Sopenharmony_ci client.write(h2test.kClientMagic, () => { 221cb0ef41Sopenharmony_ci client.write(settings.data, () => { 231cb0ef41Sopenharmony_ci client.write(settingsAck.data); 241cb0ef41Sopenharmony_ci // Prior to nghttp2 1.31.1, sending this malformed altsvc frame 251cb0ef41Sopenharmony_ci // would cause a segfault. This test is successful if a segfault 261cb0ef41Sopenharmony_ci // does not occur. 271cb0ef41Sopenharmony_ci client.write(altsvc.data, common.mustCall(() => { 281cb0ef41Sopenharmony_ci client.destroy(); 291cb0ef41Sopenharmony_ci })); 301cb0ef41Sopenharmony_ci }); 311cb0ef41Sopenharmony_ci }); 321cb0ef41Sopenharmony_ci }); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci // An error may or may not be emitted on the client side, we don't care 351cb0ef41Sopenharmony_ci // either way if it is, but we don't want to die if it is. 361cb0ef41Sopenharmony_ci client.on('error', () => {}); 371cb0ef41Sopenharmony_ci client.on('close', common.mustCall(() => server.close())); 381cb0ef41Sopenharmony_ci client.resume(); 391cb0ef41Sopenharmony_ci}); 40