@@ -1364,15 +1364,12 @@ added:
1364
1364
Limit the amount of time the parser will wait to receive the complete HTTP
1365
1365
headers.
1366
1366
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.
1376
1373
1377
1374
### ` server.listen() `
1378
1375
@@ -1401,9 +1398,14 @@ Limits maximum incoming headers count. If set to 0, no limit will be applied.
1401
1398
1402
1399
<!-- YAML
1403
1400
added: 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).
1404
1406
-->
1405
1407
1406
- * {number} ** Default:** ` 0 `
1408
+ * {number} ** Default:** ` 300000 `
1407
1409
1408
1410
Sets the timeout value in milliseconds for receiving the entire request from
1409
1411
the client.
@@ -2856,6 +2858,10 @@ Found'`.
2856
2858
<!-- YAML
2857
2859
added: v0.1.13
2858
2860
changes:
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.
2859
2865
- version: REPLACEME
2860
2866
pr-url: https://github.com/nodejs/node/pull/42163
2861
2867
description: The `noDelay` option now defaults to `true`.
@@ -2886,6 +2892,22 @@ changes:
2886
2892
* ` ServerResponse ` {http.ServerResponse} Specifies the ` ServerResponse ` class
2887
2893
to be used. Useful for extending the original ` ServerResponse ` . ** Default:**
2888
2894
` 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 ` .
2889
2911
* ` insecureHTTPParser ` {boolean} Use an insecure HTTP parser that accepts
2890
2912
invalid HTTP headers when ` true ` . Using the insecure parser should be
2891
2913
avoided. See [ ` --insecure-http-parser ` ] [ ] for more information.
@@ -3478,7 +3500,10 @@ try {
3478
3500
[ `response.write(data, encoding)` ] : #responsewritechunk-encoding-callback
3479
3501
[ `response.writeContinue()` ] : #responsewritecontinue
3480
3502
[ `response.writeHead()` ] : #responsewriteheadstatuscode-statusmessage-headers
3503
+ [ `server.headersTimeout` ] : #serverheaderstimeout
3504
+ [ `server.keepAliveTimeout` ] : #serverkeepalivetimeout
3481
3505
[ `server.listen()` ] : net.md#serverlisten
3506
+ [ `server.requestTimeout` ] : #serverrequesttimeout
3482
3507
[ `server.timeout` ] : #servertimeout
3483
3508
[ `setHeader(name, value)` ] : #requestsetheadername-value
3484
3509
[ `socket.connect()` ] : net.md#socketconnectoptions-connectlistener
0 commit comments