11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) common.skip('missing crypto'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst assert = require('node:assert'); 71cb0ef41Sopenharmony_ciconst http2 = require('node:http2'); 81cb0ef41Sopenharmony_ciconst debug = require('node:util').debuglog('test'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst testResBody = 'response content'; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci{ 131cb0ef41Sopenharmony_ci // Invalid link header value 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const server = http2.createServer(); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci server.on('request', common.mustCall((req, res) => { 181cb0ef41Sopenharmony_ci debug('Server sending early hints...'); 191cb0ef41Sopenharmony_ci res.writeEarlyHints({ link: BigInt(100) }); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci debug('Server sending full response...'); 221cb0ef41Sopenharmony_ci res.end(testResBody); 231cb0ef41Sopenharmony_ci })); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci server.listen(0); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci server.on('listening', common.mustCall(() => { 281cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${server.address().port}`); 291cb0ef41Sopenharmony_ci const req = client.request(); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci debug('Client sending request...'); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci req.on('headers', common.mustNotCall()); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci process.on('uncaughtException', (err) => { 361cb0ef41Sopenharmony_ci debug(`Caught an exception: ${JSON.stringify(err)}`); 371cb0ef41Sopenharmony_ci if (err.name === 'AssertionError') throw err; 381cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE'); 391cb0ef41Sopenharmony_ci process.exit(0); 401cb0ef41Sopenharmony_ci }); 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci} 43