fix: remove implicit Content-Type magic in res.set (#7145)#7283
fix: remove implicit Content-Type magic in res.set (#7145)#7283luvsharma6342 wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
notadev99
left a comment
There was a problem hiding this comment.
This is a behavior-breaking change — today res.set('Content-Type', 'text/plain') yields text/plain; charset=utf-8 and 'html' resolves to text/html; charset=utf-8; after this both pass through verbatim. A few things worth nailing down:
Release target. Which line is this aimed at? Dropping the implicit charset changes real responses, so it reads like major-version material rather than a patch.
Migration path / blast radius. The JSDoc now points to res.type() for charset and shorthand, which is the right pointer. Can you confirm the common res.send('...') path (no explicit Content-Type) still emits charset=utf-8? The two res.send test edits suggest the default may now drop charset as well, which would be a much wider change than just explicit res.set calls.
Compat note. Serving text/html with no charset lets a browser sniff the encoding. Modern browsers default to UTF-8 so this is mostly historical, but a line in the changelog/migration notes would help anyone relying on the implicit charset know to switch to res.type().
Coverage for the new pass-through behavior looks good.
What’s included in the PR
lib/response.js: removed the Content-Type “magic” fromres.set(no implicit MIME lookup / no charset injection); updated JSDoctest/res.set.js: added assertions for pass-throughContent-Typetest/res.send.js: updated expectations for Buffer/Uint8Array cases that previously depended on the oldres.setbehaviorTests I ran locally
npx mocha ... test/res.set.js(passing)npx mocha ... test/res.send.js(passing)