| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -463,7 +463,11 @@ function _storeHeader(firstLine, headers) { | |||
| 463 | 463 | header += 'Connection: keep-alive\r\n'; | |
| 464 | 464 | if (this._keepAliveTimeout && this._defaultKeepAlive) { | |
| 465 | 465 | const timeoutSeconds = MathFloor(this._keepAliveTimeout / 1000); | |
| 466 | - header += `Keep-Alive: timeout=${timeoutSeconds}\r\n`; | ||
| 466 | + let max = ''; | ||
| 467 | + if (~~this._maxRequestsPerSocket > 0) { | ||
| 468 | + max = `, max=${this._maxRequestsPerSocket}`; | ||
| 469 | + } | ||
| 470 | + header += `Keep-Alive: timeout=${timeoutSeconds}${max}\r\n`; | ||
| 467 | 471 | } | |
| 468 | 472 | } else { | |
| 469 | 473 | this._last = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -922,6 +922,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) { | |||
| 922 | 922 | ||
| 923 | 923 | const res = new server[kServerResponse](req); | |
| 924 | 924 | res._keepAliveTimeout = server.keepAliveTimeout; | |
| 925 | + res._maxRequestsPerSocket = server.maxRequestsPerSocket; | ||
| 925 | 926 | res._onPendingData = updateOutgoingData.bind(undefined, | |
| 926 | 927 | socket, state); | |
| 927 | 928 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ function assertResponse(headers, body, expectClosed) { | |||
| 14 | 14 | assert.match(body, /Hello World!/m); | |
| 15 | 15 | } else { | |
| 16 | 16 | assert.match(headers, /Connection: keep-alive\r\n/m); | |
| 17 | - assert.match(headers, /Keep-Alive: timeout=5\r\n/m); | ||
| 17 | + assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m); | ||
| 18 | 18 | assert.match(body, /Hello World!/m); | |
| 19 | 19 | } | |
| 20 | 20 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,11 +10,11 @@ const bodySent = 'This is my request'; | |||
| 10 | 10 | function assertResponse(headers, body, expectClosed) { | |
| 11 | 11 | if (expectClosed) { | |
| 12 | 12 | assert.match(headers, /Connection: close\r\n/m); | |
| 13 | - assert.strictEqual(headers.search(/Keep-Alive: timeout=5\r\n/m), -1); | ||
| 13 | + assert.strictEqual(headers.search(/Keep-Alive: timeout=5, max=3\r\n/m), -1); | ||
| 14 | 14 | assert.match(body, /Hello World!/m); | |
| 15 | 15 | } else { | |
| 16 | 16 | assert.match(headers, /Connection: keep-alive\r\n/m); | |
| 17 | - assert.match(headers, /Keep-Alive: timeout=5\r\n/m); | ||
| 17 | + assert.match(headers, /Keep-Alive: timeout=5, max=3\r\n/m); | ||
| 18 | 18 | assert.match(body, /Hello World!/m); | |
| 19 | 19 | } | |
| 20 | 20 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments