@@ -1364,15 +1364,12 @@ added:
13641364Limit the amount of time the parser will wait to receive the complete HTTP
13651365headers.
13661366
1367- In case of inactivity, the rules defined in [`server.timeout`][] apply. However,
1368- that inactivity based timeout would still allow the connection to be kept open
1369- if the headers are being sent very slowly (by default, up to a byte per 2
1370- minutes). In order to prevent this, whenever header data arrives an additional
1371- check is made that more than `server.headersTimeout` milliseconds has not
1372- passed since the connection was established. If the check fails, a `'timeout'`
1373- event is emitted on the server object, and (by default) the socket is destroyed.
1374- See [`server.timeout`][] for more information on how timeout behavior can be
1375- customized.
1367+ If the timeout expires, the server responds with status 408 without
1368+ forwarding the request to the request listener and then closes the connection.
1369+
1370+ It must be set to a non-zero value (e.g. 120 seconds) to protect against
1371+ potential Denial-of-Service attacks in case the server is deployed without a
1372+ reverse proxy in front.
13761373
13771374### `server.listen()`
13781375
@@ -1401,9 +1398,14 @@ Limits maximum incoming headers count. If set to 0, no limit will be applied.
14011398
14021399<!-- YAML
14031400added: v14.11.0
1401+ changes:
1402+ - version: REPLACEME
1403+ pr-url: https://github.com/nodejs/node/pull/41263
1404+ description: The default request timeout changed
1405+ from no timeout to 300s (5 minutes).
14041406-->
14051407
1406- * {number} **Default:** `0 `
1408+ * {number} **Default:** `300000 `
14071409
14081410Sets the timeout value in milliseconds for receiving the entire request from
14091411the client.
@@ -2856,6 +2858,10 @@ Found'`.
28562858<!-- YAML
28572859added: v0.1.13
28582860changes:
2861+ - version: REPLACEME
2862+ pr-url: https://github.com/nodejs/node/pull/41263
2863+ description: The `requestTimeout`, `headersTimeout`, `keepAliveTimeout` and
2864+ `connectionsCheckingInterval` are supported now.
28592865 - version: REPLACEME
28602866 pr-url: https://github.com/nodejs/node/pull/42163
28612867 description: The `noDelay` option now defaults to `true`.
@@ -2886,6 +2892,22 @@ changes:
28862892 * `ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` class
28872893 to be used. Useful for extending the original `ServerResponse`. **Default:**
28882894 `ServerResponse`.
2895+ * `requestTimeout`: Sets the timeout value in milliseconds for receiving
2896+ the entire request from the client.
2897+ See [`server.requestTimeout`][] for more information.
2898+ **Default:** `300000`.
2899+ * `headersTimeout`: Sets the timeout value in milliseconds for receiving
2900+ the complete HTTP headers from the client.
2901+ See [`server.headersTimeout`][] for more information.
2902+ **Default:** `60000`.
2903+ * `keepAliveTimeout`: The number of milliseconds of inactivity a server
2904+ needs to wait for additional incoming data, after it has finished writing
2905+ the last response, before a socket will be destroyed.
2906+ See [`server.keepAliveTimeout`][] for more information.
2907+ **Default:** `5000`.
2908+ * `connectionsCheckingInterval`: Sets the interval value in milliseconds to
2909+ check for request and headers timeout in incomplete requests.
2910+ **Default:** `30000`.
28892911 * `insecureHTTPParser` {boolean} Use an insecure HTTP parser that accepts
28902912 invalid HTTP headers when `true`. Using the insecure parser should be
28912913 avoided. See [`--insecure-http-parser`][] for more information.
@@ -3478,7 +3500,10 @@ try {
34783500[`response.write(data, encoding)`]: #responsewritechunk-encoding-callback
34793501[`response.writeContinue()`]: #responsewritecontinue
34803502[`response.writeHead()`]: #responsewriteheadstatuscode-statusmessage-headers
3503+ [`server.headersTimeout`]: #serverheaderstimeout
3504+ [`server.keepAliveTimeout`]: #serverkeepalivetimeout
34813505[`server.listen()`]: net.md#serverlisten
3506+ [`server.requestTimeout`]: #serverrequesttimeout
34823507[`server.timeout`]: #servertimeout
34833508[`setHeader(name, value)`]: #requestsetheadername-value
34843509[`socket.connect()`]: net.md#socketconnectoptions-connectlistener
0 commit comments