Skip to content

fix(response): keep custom Content-Type values in res.set() - #7537

Closed
princejain756 wants to merge 1 commit into
expressjs:masterfrom
princejain756:fix-content-type-false
Closed

princejain756 wants to merge 1 commit into
expressjs:masterfrom
princejain756:fix-content-type-false

Conversation

@princejain756

@princejain756 princejain756 commented Oct 21, 2026 •

Copy link
Copy Markdown

res.set('Content-Type', 'some-custom-type') sent Content-Type: false: mime.contentType() returns false for an unrecognized slashless value and the boolean was written straight to the header.

The lookup result now falls back to the caller's string, matching the behavior the issue asks for. Values that already contain / and known type names are unchanged.

Fixes #7034

mime.contentType() returns false for an unrecognized slashless value
such as 'some-custom-type', and res.set() then wrote the literal
header value 'false'. The original string is kept when lookup fails.

Fixes expressjs#7034
@krzysdz

krzysdz commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Duplicate of #7035

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

res.set('Content-Type') silently sets header to literal string 'false' for unknown types

2 participants