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