restify/node-restify
View on GitHubAdditional content-type parameters are thrown away
Open
#1589 opened on Jan 2, 2018
BugCriticalGood First IssueHelp WantedNeeds Discussion
Description
- Used appropriate template for the issue type
- Searched both open and closed issues for duplicates of this issue
- Title adequately and concisely reflects the feature or the bug
Bug Report
Restify Version
6.3.4
Node.js Version
8.9.1
Expected behaviour
Given the following code, I would expect the content-type string I set to be used.
res.contentType = "text/plain; version=0.0.4; charset=utf-8"
res.send(...)
Should produce:
Content-Type: text/plain; version=0.0.4; charset=utf-8
For context, the content-type I'm using comes from: Prometheus client, Prometheus docs
Actual behaviour
Only the contents of the string before the first ; are used, resulting in:
Content-Type: text/plain
Repro case
var restify = require('restify');
const server = restify.createServer({
name: 'myapp',
version: '1.0.0'
});
server.get('/test', function (req, res, next) {
res.contentType = "text/plain; version=0.0.4; charset=utf-8"
res.send(200, "some text")
return next();
});
server.listen(8080, function () {
console.log('%s listening at %s', server.name, server.url);
});
Cause
The string is split here, throwing away the rest:
Are you willing and able to fix this?
Maybe :smile:
Assuming there isn't some reason this is intended behaviour, I can have a look at fixing.