mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> PR-URL: https://github.com/nodejs/node/pull/58535 Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
// Flags: --expose-internals --no-warnings
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const { HTTPParser } = require('internal/http/common');
|
|
|
|
// Test that the `HTTPParser` instance is cleaned up before being returned to
|
|
// the pool to avoid memory retention issues.
|
|
|
|
const kOnTimeout = HTTPParser.kOnTimeout | 0;
|
|
const server = http.createServer();
|
|
|
|
server.on('request', common.mustCall((request, response) => {
|
|
const parser = request.socket.parser;
|
|
|
|
assert.strictEqual(typeof parser[kOnTimeout], 'function');
|
|
|
|
request.socket.on('close', common.mustCall(() => {
|
|
assert.strictEqual(parser[kOnTimeout], null);
|
|
}));
|
|
|
|
response.end();
|
|
server.close();
|
|
}));
|
|
|
|
server.listen(common.mustCall(() => {
|
|
const request = http.get({
|
|
headers: { Connection: 'close' },
|
|
port: server.address().port,
|
|
joinDuplicateHeaders: true
|
|
});
|
|
let parser;
|
|
|
|
request.on('socket', common.mustCall(() => {
|
|
parser = request.parser;
|
|
assert.strictEqual(typeof parser.onIncoming, 'function');
|
|
assert.strictEqual(parser.joinDuplicateHeaders, true);
|
|
}));
|
|
|
|
request.on('response', common.mustCall((response) => {
|
|
response.resume();
|
|
response.on('end', common.mustCall(() => {
|
|
assert.strictEqual(parser.onIncoming, null);
|
|
assert.strictEqual(parser.joinDuplicateHeaders, null);
|
|
}));
|
|
}));
|
|
}));
|