Skip to content

Don't write a response body for null body status codes in sendStatus - #336

Merged
naorpeled merged 3 commits into
jeremydaly:mainfrom
programmer4285:null-body-status-codes
Aug 8, 2026
Merged

Don't write a response body for null body status codes in sendStatus#336
naorpeled merged 3 commits into
jeremydaly:mainfrom
programmer4285:null-body-status-codes

Conversation

@programmer4285

Copy link
Copy Markdown
Contributor

resolves #335

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates sendStatus to avoid emitting a reason-phrase response body for HTTP status codes that must not include content (1xx, 204, 205, 304), aligning the framework’s behavior with RFC 9110 semantics.

Changes:

  • Added statusBodyLookup(status) utility to return an empty string for no-body status codes.
  • Updated RESPONSE.sendStatus() to use statusBodyLookup instead of statusLookup.
  • Added unit tests covering statusBodyLookup for common status codes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/lib/utils.js Adds statusBodyLookup to suppress bodies for no-body HTTP status codes.
src/lib/response.js Switches sendStatus to use statusBodyLookup when generating the response body.
tests/utils.unit.js Adds unit tests for the new statusBodyLookup helper.

Comment thread src/lib/utils.js
Comment thread __tests__/utils.unit.js
Comment thread src/lib/response.js
@programmer4285

Copy link
Copy Markdown
Contributor Author

hi @naorpeled, what is the process for getting this PR merged? should i address the comments from copilot?

@naorpeled

Copy link
Copy Markdown
Collaborator

hi @naorpeled, what is the process for getting this PR merged? should i address the comments from copilot?

Hey,
Yes, once the comments are addressed I'll merge the PR 🙏

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@naorpeled
naorpeled merged commit ffb07a7 into jeremydaly:main Aug 8, 2026
8 checks passed
@naorpeled

Copy link
Copy Markdown
Collaborator

Thanks @programmer4285 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] sendStatus writes a response body for status codes that should not have a body

3 participants