@@ -421,8 +421,9 @@ the data is read it will consume memory that can eventually lead to a
421421For 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,
426427identified 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';
20592060After response header was sent to the client, this property indicates the
20602061status 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