@@ -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
@@ -2074,6 +2075,21 @@ response.statusMessage = 'Not found';
2074
2075
After response header was sent to the client, this property indicates the
2075
2076
status message which was sent out.
2076
2077
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
+
2077
2093
### ` response.uncork() `
2078
2094
2079
2095
<!-- YAML
@@ -3860,6 +3876,7 @@ Set the maximum number of idle HTTP parsers.
3860
3876
[ `response.getHeader()` ] : #responsegetheadername
3861
3877
[ `response.setHeader()` ] : #responsesetheadername-value
3862
3878
[ `response.socket` ] : #responsesocket
3879
+ [ `response.strictContentLength` ] : #responsestrictcontentlength
3863
3880
[ `response.writableEnded` ] : #responsewritableended
3864
3881
[ `response.writableFinished` ] : #responsewritablefinished
3865
3882
[ `response.write()` ] : #responsewritechunk-encoding-callback
0 commit comments