Skip to content

Preserve unknown Content-Type values in res.set() - #7384

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

Preserve unknown Content-Type values in res.set()#7384
ShreyashShaurya wants to merge 1 commit into
expressjs:masterfrom
ShreyashShaurya:fix-content-type-false

Conversation

@ShreyashShaurya

Copy link
Copy Markdown

Summary

When res.set('Content-Type', value) is called with an unknown content type,
mime.contentType(value) returns false. Express currently forwards that
value to setHeader, resulting in a Content-Type: false header.

This change preserves the original value when MIME lookup fails.

Changes

  • Preserve unknown Content-Type values by falling back to the original input.
  • Add a regression test covering this behavior.

Fixes#7034

@krzysdz

Copy link
Copy Markdown
Contributor

Duplicate of#7035

@krzysdzkrzysdz marked this as a duplicate of #7035Jul 18, 2026
@krzysdzkrzysdz closed this Jul 18, 2026
@ShreyashShaurya
ShreyashShaurya deleted the fix-content-type-false branch July 18, 2026 18:12
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

@ShreyashShaurya@krzysdz