Skip to content

Commit 1b87cb6

Browse files
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 fe514bf commit 1b87cb6

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
@@ -423,8 +423,9 @@ the data is read it will consume memory that can eventually lead to a
423423
For backward compatibility, `res` will only emit `'error'` if there is an
424424
`'error'` listener registered.
425425

426-
Set `Content-Length` header to limit the response body size. Mismatching the
427-
`Content-Length` header value will result in an \[`Error`]\[] being thrown,
426+
Set `Content-Length` header to limit the response body size.
427+
If [`response.strictContentLength`][] is set to `true`, mismatching the
428+
`Content-Length` header value will result in an `Error` being thrown,
428429
identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][].
429430

430431
`Content-Length` value should be in bytes, not characters. Use
@@ -2074,6 +2075,21 @@ response.statusMessage = 'Not found';
20742075
After response header was sent to the client, this property indicates the
20752076
status message which was sent out.
20762077

2078+
### `response.strictContentLength`
2079+
2080+
<!-- YAML
2081+
added:
2082+
- v18.10.0
2083+
- v16.18.0
2084+
-->
2085+
2086+
* {boolean} **Default:** `false`
2087+
2088+
If set to `true`, Node.js will check whether the `Content-Length`
2089+
header value and the size of the body, in bytes, are equal.
2090+
Mismatching the `Content-Length` header value will result
2091+
in an `Error` being thrown, identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][].
2092+
20772093
### `response.uncork()`
20782094

20792095
<!-- YAML
@@ -3860,6 +3876,7 @@ Set the maximum number of idle HTTP parsers.
38603876
[`response.getHeader()`]: #responsegetheadername
38613877
[`response.setHeader()`]: #responsesetheadername-value
38623878
[`response.socket`]: #responsesocket
3879+
[`response.strictContentLength`]: #responsestrictcontentlength
38633880
[`response.writableEnded`]: #responsewritableended
38643881
[`response.writableFinished`]: #responsewritablefinished
38653882
[`response.write()`]: #responsewritechunk-encoding-callback

0 commit comments

Comments
 (0)