Skip to content

Commit 3afbb92

Browse files
marco-ippolitodanielleadams
authored andcommitted
doc: add response.strictContentLength to documentation
PR-URL: #46627 Refs: #44378 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Harshitha K P <[email protected]>
1 parent 36e080c commit 3afbb92

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

doc/api/http.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,9 @@ the data is read it will consume memory that can eventually lead to a
421421
For backward compatibility, `res` will only emit `'error'` if there is an
422422
`'error'` listener registered.
423423

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,
426427
identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][].
427428

428429
`Content-Length` value should be in bytes, not characters. Use
@@ -2059,6 +2060,21 @@ response.statusMessage = 'Not found';
20592060
After response header was sent to the client, this property indicates the
20602061
status message which was sent out.
20612062

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+
20622078
### `response.uncork()`
20632079

20642080
<!-- YAML
@@ -3810,6 +3826,7 @@ Set the maximum number of idle HTTP parsers.
38103826
[`response.getHeader()`]: #responsegetheadername
38113827
[`response.setHeader()`]: #responsesetheadername-value
38123828
[`response.socket`]: #responsesocket
3829+
[`response.strictContentLength`]: #responsestrictcontentlength
38133830
[`response.writableEnded`]: #responsewritableended
38143831
[`response.writableFinished`]: #responsewritablefinished
38153832
[`response.write()`]: #responsewritechunk-encoding-callback

0 commit comments

Comments
 (0)