From 3afbb92bb4fc47905cafc7125c974fad12427206 Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Tue, 14 Feb 2023 20:55:52 +0100 Subject: [PATCH] doc: add response.strictContentLength to documentation PR-URL: https://github.com/nodejs/node/pull/46627 Refs: https://github.com/nodejs/node/pull/44378 Reviewed-By: Robert Nagy Reviewed-By: Antoine du Hamel Reviewed-By: Paolo Insogna Reviewed-By: Luigi Pinca Reviewed-By: Harshitha K P --- doc/api/http.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 733325a005aabf..0b8c7e7ab1f206 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -421,8 +421,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 @@ -2059,6 +2060,21 @@ 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()`