2017-09-28 23:22:50 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
|
|
|
const http2 = require('http2');
|
|
|
|
|
|
|
|
const server = http2.createServer();
|
|
|
|
|
2017-12-12 11:34:17 -08:00
|
|
|
const types = [
|
|
|
|
true,
|
|
|
|
{},
|
|
|
|
[],
|
|
|
|
null,
|
|
|
|
new Date()
|
|
|
|
];
|
2017-09-28 23:22:50 -05:00
|
|
|
|
2017-12-12 11:34:17 -08:00
|
|
|
server.on('stream', common.mustCall((stream) => {
|
|
|
|
const session = stream.session;
|
2017-09-28 23:22:50 -05:00
|
|
|
|
2018-03-19 13:33:46 +01:00
|
|
|
types.forEach((input) => {
|
2017-12-12 11:34:17 -08:00
|
|
|
common.expectsError(
|
2018-03-19 13:33:46 +01:00
|
|
|
() => session.goaway(input),
|
2017-12-12 11:34:17 -08:00
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
type: TypeError,
|
2018-03-19 13:33:46 +01:00
|
|
|
message: 'The "code" argument must be of type number. Received type ' +
|
|
|
|
typeof input
|
2017-12-12 11:34:17 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
common.expectsError(
|
2018-03-19 13:33:46 +01:00
|
|
|
() => session.goaway(0, input),
|
2017-12-12 11:34:17 -08:00
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
type: TypeError,
|
2018-03-19 13:33:46 +01:00
|
|
|
message: 'The "lastStreamID" argument must be of type number. ' +
|
|
|
|
`Received type ${typeof input}`
|
2017-12-12 11:34:17 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
common.expectsError(
|
2018-03-19 13:33:46 +01:00
|
|
|
() => session.goaway(0, 0, input),
|
2017-12-12 11:34:17 -08:00
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
type: TypeError,
|
|
|
|
message: 'The "opaqueData" argument must be one of type Buffer, ' +
|
2018-03-19 13:33:46 +01:00
|
|
|
`TypedArray, or DataView. Received type ${typeof input}`
|
2017-12-12 11:34:17 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.session.destroy();
|
|
|
|
}));
|
2017-09-28 23:22:50 -05:00
|
|
|
|
|
|
|
server.listen(
|
|
|
|
0,
|
|
|
|
common.mustCall(() => {
|
|
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
|
|
const req = client.request();
|
|
|
|
req.resume();
|
2017-12-12 11:34:17 -08:00
|
|
|
req.on('close', common.mustCall(() => {
|
|
|
|
client.close();
|
|
|
|
server.close();
|
|
|
|
}));
|
2017-09-28 23:22:50 -05:00
|
|
|
})
|
|
|
|
);
|