-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
http: refactor headersTimeout and requestTimeout logic #41263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1364,15 +1364,12 @@ added: | |
Limit the amount of time the parser will wait to receive the complete HTTP | ||
headers. | ||
|
||
In case of inactivity, the rules defined in [`server.timeout`][] apply. However, | ||
that inactivity based timeout would still allow the connection to be kept open | ||
if the headers are being sent very slowly (by default, up to a byte per 2 | ||
minutes). In order to prevent this, whenever header data arrives an additional | ||
check is made that more than `server.headersTimeout` milliseconds has not | ||
passed since the connection was established. If the check fails, a `'timeout'` | ||
event is emitted on the server object, and (by default) the socket is destroyed. | ||
See [`server.timeout`][] for more information on how timeout behavior can be | ||
customized. | ||
If the timeout expires, the server responds with status 408 without | ||
forwarding the request to the request listener and then closes the connection. | ||
|
||
It must be set to a non-zero value (e.g. 120 seconds) to protect against | ||
potential Denial-of-Service attacks in case the server is deployed without a | ||
reverse proxy in front. | ||
|
||
### `server.listen()` | ||
|
||
|
@@ -1401,9 +1398,14 @@ Limits maximum incoming headers count. If set to 0, no limit will be applied. | |
|
||
<!-- YAML | ||
added: v14.11.0 | ||
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/41263 | ||
description: The default request timeout changed | ||
from no timeout to 300s (5 minutes). | ||
--> | ||
|
||
* {number} **Default:** `0` | ||
* {number} **Default:** `300000` | ||
ronag marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey! I believe this change should be added to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @julien-f Yes, it should. Are you willing to send a PR about this or will I do that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do it, I don't have the time at the moment. Thank you 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok! |
||
|
||
Sets the timeout value in milliseconds for receiving the entire request from | ||
the client. | ||
|
@@ -2856,6 +2858,10 @@ Found'`. | |
<!-- YAML | ||
added: v0.1.13 | ||
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/41263 | ||
description: The `requestTimeout`, `headersTimeout`, `keepAliveTimeout` and | ||
`connectionsCheckingInterval` are supported now. | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/42163 | ||
description: The `noDelay` option now defaults to `true`. | ||
|
@@ -2886,6 +2892,22 @@ changes: | |
* `ServerResponse` {http.ServerResponse} Specifies the `ServerResponse` class | ||
to be used. Useful for extending the original `ServerResponse`. **Default:** | ||
`ServerResponse`. | ||
* `requestTimeout`: Sets the timeout value in milliseconds for receiving | ||
ShogunPanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
the entire request from the client. | ||
See [`server.requestTimeout`][] for more information. | ||
**Default:** `300000`. | ||
* `headersTimeout`: Sets the timeout value in milliseconds for receiving | ||
the complete HTTP headers from the client. | ||
See [`server.headersTimeout`][] for more information. | ||
**Default:** `60000`. | ||
* `keepAliveTimeout`: The number of milliseconds of inactivity a server | ||
needs to wait for additional incoming data, after it has finished writing | ||
the last response, before a socket will be destroyed. | ||
See [`server.keepAliveTimeout`][] for more information. | ||
**Default:** `5000`. | ||
* `connectionsCheckingInterval`: Sets the interval value in milliseconds to | ||
check for request and headers timeout in incomplete requests. | ||
ShogunPanda marked this conversation as resolved.
Show resolved
Hide resolved
|
||
**Default:** `30000`. | ||
* `insecureHTTPParser` {boolean} Use an insecure HTTP parser that accepts | ||
invalid HTTP headers when `true`. Using the insecure parser should be | ||
avoided. See [`--insecure-http-parser`][] for more information. | ||
|
@@ -3478,7 +3500,10 @@ try { | |
[`response.write(data, encoding)`]: #responsewritechunk-encoding-callback | ||
[`response.writeContinue()`]: #responsewritecontinue | ||
[`response.writeHead()`]: #responsewriteheadstatuscode-statusmessage-headers | ||
[`server.headersTimeout`]: #serverheaderstimeout | ||
[`server.keepAliveTimeout`]: #serverkeepalivetimeout | ||
[`server.listen()`]: net.md#serverlisten | ||
[`server.requestTimeout`]: #serverrequesttimeout | ||
[`server.timeout`]: #servertimeout | ||
[`setHeader(name, value)`]: #requestsetheadername-value | ||
[`socket.connect()`]: net.md#socketconnectoptions-connectlistener | ||
|
Uh oh!
There was an error while loading. Please reload this page.