mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

Co-Authored-By: Matteo Collina <matteo.collina@gmail.com> Co-Authored-By: Livia Medeiros <livia@cirno.name> PR-URL: https://github.com/nodejs/node/pull/44180 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const assert = require('node:assert');
|
|
const http2 = require('node:http2');
|
|
const debug = require('node:util').debuglog('test');
|
|
|
|
const testResBody = 'response content';
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('request', common.mustCall((req, res) => {
|
|
debug('Server sending early hints...');
|
|
res.writeEarlyHints('bad argument value');
|
|
|
|
debug('Server sending full response...');
|
|
res.end(testResBody);
|
|
}));
|
|
|
|
server.listen(0);
|
|
|
|
server.on('listening', common.mustCall(() => {
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
const req = client.request();
|
|
|
|
debug('Client sending request...');
|
|
|
|
req.on('headers', common.mustNotCall());
|
|
|
|
process.on('uncaughtException', (err) => {
|
|
debug(`Caught an exception: ${JSON.stringify(err)}`);
|
|
if (err.name === 'AssertionError') throw err;
|
|
assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE');
|
|
process.exit(0);
|
|
});
|
|
}));
|