Skip to content

Commit

Permalink
http: null the joinDuplicateHeaders property on cleanup
Browse files Browse the repository at this point in the history
Null the `joinDuplicateHeaders` property when the parser is freed.

Refs: #45982
PR-URL: #48608
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
  • Loading branch information
lpinca authored and ruyadorno committed Sep 16, 2023
1 parent 6ec5798 commit 01746c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function cleanParser(parser) {
parser[kOnTimeout] = null;
parser._consumed = false;
parser.onIncoming = null;
parser.joinDuplicateHeaders = null;
}

function prepareError(err, parser, rawPacket) {
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-http-parser-memory-retention.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@ server.on('request', common.mustCall((request, response) => {
}));

server.listen(common.mustCall(() => {
const request = http.get({ port: server.address().port });
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);
}));
}));
}));

0 comments on commit 01746c7

Please sign in to comment.