mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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:
1 parent
b19564b9d2
commit
a2cd8b316c
3 files changed
+36
-2
No files matched your search
@@ -3615,6 +3615,16 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
## `http.setMaxIdleHTTPParsers`
|
||||
|
||||
<!-- YAML
|
||||
added: REPLACEME
|
||||
-->
|
||||
|
||||
* {number}
|
||||
|
||||
Set the maximum number of idle HTTP parsers. **Default:** `1000`.
|
||||
|
||||
[RFC 8187]: https://www.rfc-editor.org/rfc/rfc8187.txt
|
||||
[`'checkContinue'`]: #event-checkcontinue
|
||||
[`'finish'`]: #event-finish
|
||||
|
||||
+7
-2
@@ -27,9 +27,10 @@ const {
|
||||
ObjectDefineProperty,
|
||||
} = primordials;
|
||||
|
||||
const { validateInteger } = require('internal/validators');
|
||||
const httpAgent = require('_http_agent');
|
||||
const { ClientRequest } = require('_http_client');
|
||||
const { methods } = require('_http_common');
|
||||
const { methods, parsers } = require('_http_common');
|
||||
const { IncomingMessage } = require('_http_incoming');
|
||||
const {
|
||||
validateHeaderName,
|
||||
@@ -123,7 +124,11 @@ module.exports = {
|
||||
validateHeaderName,
|
||||
validateHeaderValue,
|
||||
get,
|
||||
request
|
||||
request,
|
||||
setMaxIdleHTTPParsers(max) {
|
||||
validateInteger(max, 'max', 1);
|
||||
parsers.max = max;
|
||||
}
|
||||
};
|
||||
|
||||
ObjectDefineProperty(module.exports, 'maxHeaderSize', {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user