Repository navigation
fix(response): preserve user-supplied content-type parameters on send - #2022
Open
CloudCorpRecords wants to merge 1 commit into
Open
CloudCorpRecords wants to merge 1 commit into
CloudCorpRecords wants to merge 1 commit into
Conversation
res.contentType = 'text/plain; version=0.0.4' was stripped to 'text/plain' because send() split the type on ';' for formatter lookup and then used the stripped value for the outgoing Content-Type header. Keep the parameters aside for lookup, then restore them on the header. res.charSet() behavior is unchanged. Fixes restify#1589. Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-Submission Checklist
make prepush(eslint clean; 902 nodeunit assertions and 217 mocha plugin tests pass)Issues
Closes:
Changes
res.send()split the content type on;to derive the base type for formatter lookup, but then reused that stripped value for the outgoingContent-Typeheader. Sores.contentType = 'text/plain; version=0.0.4; charset=utf-8'went out as plaintext/plain, silently dropping parameters like the Prometheus expositionversion.The fix keeps the parameters aside before formatter lookup and restores them on the header that is actually sent. The base type is still what drives formatter selection, and
res.charSet()behavior is unchanged (its charset is appended as before, with no duplication of user params).Tests added in
test/response.test.js:res.contentType = 'text/plain; version=0.0.4; charset=utf-8'produces exactly thatContent-Typeheader on the response (verified failing before the fix)res.charSet('utf-8')still yieldstext/plain; charset=utf-8with no duplicationSigned-off-by: Rene Turcios 95189389+CloudCorpRecords@users.noreply.github.com