2019-08-22 11:42:46 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
2019-08-24 20:42:11 +02:00
|
|
|
const assert = require('assert');
|
2019-08-22 11:42:46 +02:00
|
|
|
const { createServer } = require('http');
|
|
|
|
const { connect } = require('net');
|
|
|
|
|
2019-08-24 20:42:11 +02:00
|
|
|
// 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.
|
|
|
|
|
2019-08-22 11:42:46 +02:00
|
|
|
const server = createServer(common.mustCall((req, res) => {
|
2019-08-24 20:42:11 +02:00
|
|
|
req.on('end', common.mustCall(() => {
|
|
|
|
const parser = req.socket.parser;
|
|
|
|
assert.strictEqual(parser.incoming, req);
|
|
|
|
process.nextTick(() => {
|
|
|
|
assert.strictEqual(parser.incoming, null);
|
|
|
|
});
|
|
|
|
}));
|
2019-08-22 11:42:46 +02:00
|
|
|
res.end('hello world');
|
|
|
|
}));
|
|
|
|
|
|
|
|
server.unref();
|
|
|
|
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
|
|
const client = connect(server.address().port);
|
|
|
|
|
|
|
|
const req = [
|
|
|
|
'POST / HTTP/1.1',
|
|
|
|
`Host: localhost:${server.address().port}`,
|
|
|
|
'Connection: keep-alive',
|
|
|
|
'Content-Length: 11',
|
|
|
|
'',
|
|
|
|
'hello world',
|
2021-03-26 08:51:08 -07:00
|
|
|
'',
|
2019-08-22 11:42:46 +02:00
|
|
|
].join('\r\n');
|
|
|
|
|
|
|
|
client.end(req);
|
|
|
|
}));
|