From 082a2630fd14e759270de38b7af8a6e9903dcf4e Mon Sep 17 00:00:00 2001 From: theanarkh Date: Sat, 23 Jul 2022 00:33:03 +0800 Subject: [PATCH] http: add drop request event for http server PR-URL: https://github.com/nodejs/node/pull/43806 Reviewed-By: Matteo Collina --- doc/api/http.md | 14 +++++ lib/_http_server.js | 2 +- .../test-http-keep-alive-drop-requests.js | 34 +++++++++++++ .../test-https-keep-alive-drop-requests.js | 51 +++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-http-keep-alive-drop-requests.js create mode 100644 test/parallel/test-https-keep-alive-drop-requests.js diff --git a/doc/api/http.md b/doc/api/http.md index d28895ee484..539ffb67683 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1396,6 +1396,20 @@ This event is guaranteed to be passed an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specifies a socket type other than {net.Socket}. +### Event: `'dropRequest'` + + + +* `request` {http.IncomingMessage} Arguments for the HTTP request, as it is in + the [`'request'`][] event +* `socket` {stream.Duplex} Network socket between the server and client + +When the number of requests on a socket reaches the threshold of +`server.maxRequestsPerSocket`, the server will drop new requests +and emit `'dropRequest'` event instead, then send `503` to client. + ### Event: `'request'`