Skip to content

Commit

Permalink
Remove "max" hint
Browse files Browse the repository at this point in the history
  • Loading branch information
fatal10110 committed Sep 14, 2021
1 parent c2d9664 commit 4d0ca75
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
21 changes: 3 additions & 18 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function OutgoingMessage() {
this._header = null;
this[kOutHeaders] = null;

this._maxRequestsPerSocket = null;
this._keepAliveTimeout = 0;

this._onPendingData = nop;
Expand Down Expand Up @@ -453,23 +452,9 @@ function _storeHeader(firstLine, headers) {
header += 'Connection: close' + CRLF;
} else if (shouldSendKeepAlive) {
header += 'Connection: keep-alive' + CRLF;

if (this._defaultKeepAlive) {
let keepAliveParameters = '';

if (this._keepAliveTimeout) {
const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000);
keepAliveParameters += `timeout=${timeoutSeconds}`;
}

if (this._maxRequestsPerSocket) {
if (keepAliveParameters.length > 0) keepAliveParameters += ', ';
keepAliveParameters += `max=${this._maxRequestsPerSocket}`;
}

if (keepAliveParameters.length > 0) {
header += `Keep-Alive: ${keepAliveParameters}${CRLF}`;
}
if (this._keepAliveTimeout && this._defaultKeepAlive) {
const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000);
header += `Keep-Alive: timeout=${timeoutSeconds}${CRLF}`;
}
} else {
this._last = true;
Expand Down
1 change: 0 additions & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ 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);

Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-http-keep-alive-max-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const bodySent = 'This is my request';
function assertResponse(headers, body, expectClosed) {
if (expectClosed) {
assert.match(headers, /Connection: close\r\n/m);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5, max=3\r\n/m), -1);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5\r\n/m), -1);
assert.match(body, /Hello World!/m);
} else {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5\r\n/m);
assert.match(body, /Hello World!/m);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/parallel/test-http-keep-alive-pipeline-max-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ const bodySent = 'This is my request';
function assertResponse(headers, body, expectClosed) {
if (expectClosed) {
assert.match(headers, /Connection: close\r\n/m);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5, max=3\r\n/m), -1);
assert.strictEqual(headers.search(/Keep-Alive: timeout=5\r\n/m), -1);
assert.match(body, /Hello World!/m);
} else {
assert.match(headers, /Connection: keep-alive\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m);
assert.match(headers, /Keep-Alive: timeout=5\r\n/m);
assert.match(body, /Hello World!/m);
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ server.listen(0, common.mustCall((res) => {

assert.match(responseParts[6], /HTTP\/1\.1 503 Service Unavailable/m);
assert.match(responseParts[6], /Connection: close\r\n/m);
assert.strictEqual(responseParts[6].search(/Keep-Alive: timeout=5, max=3\r\n/m), -1);
assert.strictEqual(responseParts[6].search(/Keep-Alive: timeout=5\r\n/m), -1);
assert.strictEqual(responseParts[7].search(/Hello World!/m), -1);

socket.end();
Expand Down

0 comments on commit 4d0ca75

Please sign in to comment.