@@ -423,8 +423,9 @@ the data is read it will consume memory that can eventually lead to a
423
423
For backward compatibility, ` res ` will only emit ` 'error' ` if there is an
424
424
` 'error' ` listener registered.
425
425
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,
428
429
identified by ` code: ` [ ` 'ERR_HTTP_CONTENT_LENGTH_MISMATCH' ` ] [ ] .
429
430
430
431
` Content-Length ` value should be in bytes, not characters. Use
@@ -2072,6 +2073,21 @@ response.statusMessage = 'Not found';
2072
2073
After response header was sent to the client, this property indicates the
2073
2074
status message which was sent out.
2074
2075
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
+
2075
2091
### ` response.uncork() `
2076
2092
2077
2093
<!-- YAML
@@ -3850,6 +3866,7 @@ Set the maximum number of idle HTTP parsers.
3850
3866
[ `response.getHeader()` ] : #responsegetheadername
3851
3867
[ `response.setHeader()` ] : #responsesetheadername-value
3852
3868
[ `response.socket` ] : #responsesocket
3869
+ [ `response.strictContentLength` ] : #responsestrictcontentlength
3853
3870
[ `response.writableEnded` ] : #responsewritableended
3854
3871
[ `response.writableFinished` ] : #responsewritablefinished
3855
3872
[ `response.write()` ] : #responsewritechunk-encoding-callback
0 commit comments