Skip to content

Commit

Permalink
http: close on last request
Browse files Browse the repository at this point in the history
  • Loading branch information
fatal10110 committed Sep 11, 2021
1 parent 51cf1f2 commit 6413200
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,14 +907,15 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
resOnFinish.bind(undefined,
req, res, socket, state, server));

if (req.httpVersionMajor === 1 && req.httpVersionMinor === 1
&& typeof server.maxRequestsPerSocket === 'number'
&& server.maxRequestsPerSocket < ++state.requestsCount) {
res.shouldKeepAlive = false;
res.writeHead(503, {
'Connection': 'close'
});
if (typeof server.maxRequestsPerSocket === 'number'
&& (req.httpVersionMajor === 1 && req.httpVersionMinor === 1)) {

if (server.maxRequestsPerSocket < ++state.requestsCount) {
res.writeHead(503);
res.end();
}

res.shouldKeepAlive = server.maxRequestsPerSocket > state.requestsCount
}

if (req.headers.expect !== undefined &&
Expand Down

0 comments on commit 6413200

Please sign in to comment.