http: make idle http parser count configurable

PR-URL: https://github.com/nodejs/node/pull/43974
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
This commit is contained in:
theanarkh 2022-07-29 17:00:38 +08:00 committed by GitHub
parent 447635b440
commit 20e372c242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1,19 @@
'use strict';
require('../common');
const assert = require('assert');
const httpCommon = require('_http_common');
const http = require('http');
[Symbol(), {}, [], () => {}, 1n, true, '1', null, undefined].forEach((value) => {
assert.throws(() => http.setMaxIdleHTTPParsers(value), { code: 'ERR_INVALID_ARG_TYPE' });
});
[-1, -Infinity, NaN, 0, 1.1].forEach((value) => {
assert.throws(() => http.setMaxIdleHTTPParsers(value), { code: 'ERR_OUT_OF_RANGE' });
});
[1, Number.MAX_SAFE_INTEGER].forEach((value) => {
assert.notStrictEqual(httpCommon.parsers.max, value);
http.setMaxIdleHTTPParsers(value);
assert.strictEqual(httpCommon.parsers.max, value);
});