http: provide keep-alive timeout response header · nodejs/node@36fd3da · GitHub
Skip to content

Commit 36fd3da

Browse files
ronagcodebytere
authored andcommitted
http: provide keep-alive timeout response header
In http 1.1 persistent connection protocol there is a timing race where the client sends the request and then the server kills the connection (due to inactivity) before receiving the client's request. By providing a keep-alive header it is possible to provide the client a hint of when idle timeout would occur and avoid the race. Fixes: #34560 PR-URL: #34561 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
1 parent c1abc8d commit 36fd3da

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

lib/_http_outgoing.js

Lines changed: 7 additions & 0 deletions

lib/_http_server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
743743
}
744744

745745
const res = new server[kServerResponse](req);
746+
res._keepAliveTimeout = server.keepAliveTimeout;
746747
res._onPendingData = updateOutgoingData.bind(undefined, socket, state);
747748

748749
res.shouldKeepAlive = keepAlive;
Lines changed: 28 additions & 0 deletions

0 commit comments

Comments
 (0)