Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortheanarkh <theratliter@gmail.com>2022-08-16 16:09:10 +0300
committerJuan José Arboleda <soyjuanarbol@gmail.com>2022-10-11 22:45:14 +0300
commitfa6183fc7ef06d5bf645c8f47173ab986b194cde (patch)
tree35df72ba49f9da608de4a32ae19e075c97a60833 /lib
parentff34d48d702f480aa6d11eaf83b39474257d63a3 (diff)
http: add max for http keepalive
PR-URL: https://github.com/nodejs/node/pull/44217 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/_http_outgoing.js6
-rw-r--r--lib/_http_server.js1
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js
index dcdea299685..7b1961ad978 100644
--- a/lib/_http_outgoing.js
+++ b/lib/_http_outgoing.js
@@ -463,7 +463,11 @@ function _storeHeader(firstLine, headers) {
header += 'Connection: keep-alive\r\n';
if (this._keepAliveTimeout && this._defaultKeepAlive) {
const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000);
- header += `Keep-Alive: timeout=${timeoutSeconds}\r\n`;
+ let max = '';
+ if (~~this._maxRequestsPerSocket > 0) {
+ max = `, max=${this._maxRequestsPerSocket}`;
+ }
+ header += `Keep-Alive: timeout=${timeoutSeconds}${max}\r\n`;
}
} else {
this._last = true;
diff --git a/lib/_http_server.js b/lib/_http_server.js
index be444c42120..4e23266f630 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -922,6 +922,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
const res = new server[kServerResponse](req);
res._keepAliveTimeout = server.keepAliveTimeout;
+ res._maxRequestsPerSocket = server.maxRequestsPerSocket;
res._onPendingData = updateOutgoingData.bind(undefined,
socket, state);