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 2ed33eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
20 changes: 3 additions & 17 deletions lib/_http_outgoing.js
Expand Up @@ -453,23 +453,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
4 changes: 2 additions & 2 deletions test/parallel/test-http-keep-alive-max-requests.js
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
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 2ed33eb

Please sign in to comment.