From b273c5132de8dfa1f8cf67c9881426ced1796f17 Mon Sep 17 00:00:00 2001 From: jakecastelli <38635403+jakecastelli@users.noreply.github.com> Date: Wed, 12 Jun 2024 02:09:17 +0930 Subject: [PATCH] doc, http: add `rejectNonStandardBodyWrites` option, clear its behaviour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/53396 Fixes: https://github.com/nodejs/node/issues/53035 Reviewed-By: Luigi Pinca Reviewed-By: Paolo Insogna Reviewed-By: Ulises Gascón Reviewed-By: Marco Ippolito Reviewed-By: Matteo Collina --- doc/api/http.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index 7567069f5e16c0..2a92e60e5b8983 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2427,8 +2427,9 @@ it will switch to implicit header mode and flush the implicit headers. This sends a chunk of the response body. This method may be called multiple times to provide successive parts of the body. -Writing to the body is not allowed when the request method or response status -do not support content. If an attempt is made to write to the body for a +If `rejectNonStandardBodyWrites` is set to true in `createServer` +then writing to the body is not allowed when the request method or response +status do not support content. If an attempt is made to write to the body for a HEAD request or as part of a `204` or `304`response, a synchronous `Error` with the code `ERR_HTTP_BODY_NOT_ALLOWED` is thrown. @@ -3569,6 +3570,9 @@ changes: * `uniqueHeaders` {Array} A list of response headers that should be sent only once. If the header's value is an array, the items will be joined using `; `. + * `rejectNonStandardBodyWrites` {boolean} If set to `true`, an error is thrown + when writing to an HTTP response which does not have a body. + **Default:** `false`. * `requestListener` {Function}