From 2f15078e0ae65514b5a2dfdd26b6c11086451766 Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Sun, 12 Feb 2023 16:18:15 +0100 Subject: [PATCH 1/3] doc: add response.strictContentLength to documentation --- doc/api/http.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 156099d3f9ae83..3d19ca86bbad24 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -423,8 +423,9 @@ the data is read it will consume memory that can eventually lead to a For backward compatibility, `res` will only emit `'error'` if there is an `'error'` listener registered. -Set `Content-Length` header to limit the response body size. Mismatching the -`Content-Length` header value will result in an \[`Error`]\[] being thrown, +Set `Content-Length` header to limit the response body size. +If [`response.strictContentLength`][] is set to `true`, mismatching the +`Content-Length` header value will result in an `Error` being thrown, identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][]. `Content-Length` value should be in bytes, not characters. Use @@ -2073,6 +2074,19 @@ response.statusMessage = 'Not found'; After response header was sent to the client, this property indicates the status message which was sent out. +### `response.strictContentLength` + + + +* {boolean} **Default:** `false` + +If set to `true`, Node.js will check whether the `Content-Length` +header value and the size of the body, in bytes, are equal. +Mismatching the `Content-Length` header value will result +in an `Error` being thrown, identified by `code:` [`'ERR_HTTP_CONTENT_LENGTH_MISMATCH'`][]. + ### `response.uncork()` * {boolean} **Default:** `false`