Skip to content

http module documented default behavior only triggered if undocumented option is set #53035

@earslap

Description

@earslap

Affected URL(s)

https://nodejs.org/api/http.html#responsewritechunk-encoding-callback

Description of the problem

For the http module, the documentation for response.write says:

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 304response, a synchronous Error with the code ERR_HTTP_BODY_NOT_ALLOWED is thrown.

However this is not the default behavior. By default, nodejs swallows the provided body and prints the debug message (enabled by NODE_DEBUG=http):

HTTP 77822: This type of response MUST NOT have a body. Ignoring write() calls.

The documented behavior (throwing ERR_HTTP_BODY_NOT_ALLOWED) happens only when rejectNonStandardBodyWrites option is set to true while creating a server with createServer. However this option is not documented, it does not exist in @node/types either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions