Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76f5ce5

Browse filesBrowse files
marco-ippolitoMylesBorins
authored andcommitted
doc: add response.strictContentLength to documentation
PR-URL: #46627 Refs: #44378 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Harshitha K P <harshitha014@gmail.com>
1 parent 16c507b commit 76f5ce5
Copy full SHA for 76f5ce5

File tree

Expand file treeCollapse file tree

1 file changed

+19
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+19-2Lines changed: 19 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
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
@@ -2072,6 +2073,21 @@ response.statusMessage = 'Not found';
20722073
After response header was sent to the client, this property indicates the
20732074
status message which was sent out.
20742075

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

20772093
<!-- YAML
@@ -3850,6 +3866,7 @@ Set the maximum number of idle HTTP parsers.
38503866
[`response.getHeader()`]: #responsegetheadername
38513867
[`response.setHeader()`]: #responsesetheadername-value
38523868
[`response.socket`]: #responsesocket
3869+
[`response.strictContentLength`]: #responsestrictcontentlength
38533870
[`response.writableEnded`]: #responsewritableended
38543871
[`response.writableFinished`]: #responsewritablefinished
38553872
[`response.write()`]: #responsewritechunk-encoding-callback

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.