2017-07-17 19:29:42 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2017-08-07 07:54:44 +02:00
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
2017-07-17 19:29:42 +02:00
|
|
|
const http2 = require('http2');
|
2017-12-12 20:34:17 +01:00
|
|
|
const Countdown = require('../common/countdown');
|
2017-07-17 19:29:42 +02:00
|
|
|
|
|
|
|
const server = http2.createServer();
|
|
|
|
|
|
|
|
server.on('stream', common.mustNotCall());
|
|
|
|
|
|
|
|
const count = 32;
|
|
|
|
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
2017-12-12 20:34:17 +01:00
|
|
|
client.setMaxListeners(33);
|
2017-07-17 19:29:42 +02:00
|
|
|
|
2017-12-12 20:34:17 +01:00
|
|
|
const countdown = new Countdown(count + 1, () => {
|
|
|
|
server.close();
|
|
|
|
client.close();
|
|
|
|
});
|
2017-07-17 19:29:42 +02:00
|
|
|
|
|
|
|
// nghttp2 will catch the bad header value for us.
|
|
|
|
function doTest(i) {
|
|
|
|
const req = client.request({ ':path': `bad${String.fromCharCode(i)}path` });
|
|
|
|
req.on('error', common.expectsError({
|
|
|
|
code: 'ERR_HTTP2_STREAM_ERROR',
|
|
|
|
type: Error,
|
2018-02-23 22:28:29 +01:00
|
|
|
message: 'Stream closed with error code NGHTTP2_PROTOCOL_ERROR'
|
2017-07-17 19:29:42 +02:00
|
|
|
}));
|
2017-12-12 20:34:17 +01:00
|
|
|
req.on('close', common.mustCall(() => countdown.dec()));
|
2017-07-17 19:29:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i <= count; i += 1)
|
|
|
|
doTest(i);
|
|
|
|
}));
|