Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: null the joinDuplicateHeaders property on cleanup #48608

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' },
Copy link
Member Author

@lpinca lpinca Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added only to speed up the test. There is no need to wait for the keep-alive timeout to expire.

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);
}));
}));
}));