Skip to content

Commit

Permalink
http: remove "max" hint
Browse files Browse the repository at this point in the history
  • Loading branch information
fatal10110 committed Sep 16, 2021
1 parent 063a83c commit c5ae814
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/_http_outgoing.js
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 @@ -448,7 +447,9 @@ function _storeHeader(firstLine, headers) {
} else if (!state.connection) {
const shouldSendKeepAlive = this.shouldKeepAlive &&
(state.contLen || this.useChunkedEncodingByDefault || this.agent);
if (shouldSendKeepAlive) {
if (shouldSendKeepAlive && this.maxRequestsOnConnectionReached) {
header += 'Connection: close\r\n';
} else if (shouldSendKeepAlive) {
header += 'Connection: keep-alive\r\n';
if (this._keepAliveTimeout && this._defaultKeepAlive) {
const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000);
Expand Down
1 change: 0 additions & 1 deletion lib/_http_server.js
Expand Up @@ -877,7 +877,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
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 c5ae814

Please sign in to comment.