forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-http2-fd-nan-respondfd.js
More file actions
49 lines (38 loc) · 1.08 KB
/
Copy pathtest-http2-fd-nan-respondfd.js
File metadata and controls
49 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Flags: --expose-http2
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const http2 = require('http2');
// Test that ERR_INVALID_ARG_TYPE is thrown when ServerHttp2Stream.respondWithFD
// is called with an fd value that is not of type number
const types = {
function: () => {},
object: {},
array: [],
null: null,
symbol: Symbol('test')
};
const server = http2.createServer();
server.on('stream', common.mustCall(onStream));
function onStream(stream, headers, flags) {
Object.keys(types).forEach((type) => {
common.expectsError(() => stream.respondWithFD(type), {
type: TypeError,
code: 'ERR_INVALID_ARG_TYPE',
message: 'The "fd" argument must be of type number'
});
});
stream.end('hello world');
}
server.listen(0, common.mustCall(() => {
const port = server.address().port;
const client = http2.connect(`http://localhost:${port}`);
const req = client.request();
req.resume();
req.on('end', common.mustCall(() => {
client.destroy();
server.close();
}));
req.end();
}));