-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-http-server-keepalive-end.js
More file actions
37 lines (33 loc) · 1020 Bytes
/
test-http-server-keepalive-end.js
File metadata and controls
37 lines (33 loc) · 1020 Bytes
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
'use strict';
const common = require('../common');
const assert = require('assert');
const http2 = require('http2');
// Make sure that for HTTP keepalive requests, the .on('end') event is emitted
// on the incoming request object, and that the parser instance does not hold
// on to that request object afterwards.
const server = http2.createServer(common.mustCall((req, res) => {
req.on('end', common.mustCall(() => {
const parser = req.socket.parser;
assert.strictEqual(parser.incoming, req);
process.nextTick(() => {
assert.strictEqual(parser.incoming, null);
});
}));
res.end('hello world');
}));
server.unref();
server.listen(0, common.mustCall(() => {
const client = http2.connect('http://localhost:' + server.address().port);
const req = client.request({
':method': 'POST'
});
req.end('hello world');
req.on('end', common.mustCall(() => {
process.nextTick(() => {
server.close();
req.close();
client.close();
});
}));
req.resume();
}));