2022-08-17 20:22:53 +02:00
|
|
|
'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';
|
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
{
|
|
|
|
// Invalid object value
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
const server = http2.createServer();
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
server.on('request', common.mustCall((req, res) => {
|
|
|
|
debug('Server sending early hints...');
|
|
|
|
res.writeEarlyHints('this should not be here');
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
debug('Server sending full response...');
|
|
|
|
res.end(testResBody);
|
|
|
|
}));
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
server.listen(0);
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
server.on('listening', common.mustCall(() => {
|
|
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
|
|
const req = client.request();
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
debug('Client sending request...');
|
2022-08-17 20:22:53 +02:00
|
|
|
|
2022-10-06 18:03:47 +01:00
|
|
|
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_TYPE');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}
|