@@ -421,8 +421,9 @@ the data is read it will consume memory that can eventually lead to a |
421 | 421 | For backward compatibility, `res` will only emit `'error'` if there is an |
422 | 422 | `'error'` listener registered. |
423 | 423 |
|
424 | | -Set `Content-Length` header to limit the response body size. Mismatching the |
425 | | -`Content-Length` header value will result in an \[`Error`]\[] being thrown, |
| 424 | +Set `Content-Length` header to limit the response body size. |
| 425 | +If [`response.strictContentLength`][] is set to `true`, mismatching the |
| 426 | +`Content-Length` header value will result in an `Error` being thrown, |
426 | 427 | identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][]. |
427 | 428 |
|
428 | 429 | `Content-Length` value should be in bytes, not characters. Use |
@@ -2059,6 +2060,21 @@ response.statusMessage = 'Not found'; |
2059 | 2060 | After response header was sent to the client, this property indicates the |
2060 | 2061 | status message which was sent out. |
2061 | 2062 |
|
| 2063 | +### `response.strictContentLength` |
| 2064 | + |
| 2065 | +<!-- YAML |
| 2066 | +added: |
| 2067 | + - v18.10.0 |
| 2068 | + - v16.18.0 |
| 2069 | +--> |
| 2070 | + |
| 2071 | +* {boolean} **Default:** `false` |
| 2072 | + |
| 2073 | +If set to `true`, Node.js will check whether the `Content-Length` |
| 2074 | +header value and the size of the body, in bytes, are equal. |
| 2075 | +Mismatching the `Content-Length` header value will result |
| 2076 | +in an `Error` being thrown, identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][]. |
| 2077 | + |
2062 | 2078 | ### `response.uncork()` |
2063 | 2079 |
|
2064 | 2080 | <!-- YAML |
@@ -3810,6 +3826,7 @@ Set the maximum number of idle HTTP parsers. |
3810 | 3826 | [`response.getHeader()`]: #responsegetheadername |
3811 | 3827 | [`response.setHeader()`]: #responsesetheadername-value |
3812 | 3828 | [`response.socket`]: #responsesocket |
| 3829 | +[`response.strictContentLength`]: #responsestrictcontentlength |
3813 | 3830 | [`response.writableEnded`]: #responsewritableended |
3814 | 3831 | [`response.writableFinished`]: #responsewritablefinished |
3815 | 3832 | [`response.write()`]: #responsewritechunk-encoding-callback |
|