diff --git a/lib/response.js b/lib/response.js index f965e539dd2..bc2bc6fb438 100644 --- a/lib/response.js +++ b/lib/response.js @@ -673,7 +673,7 @@ res.header = function header(field, val) { if (Array.isArray(value)) { throw new TypeError('Content-Type cannot be set to an Array'); } - value = mime.contentType(value) + value = mime.contentType(value) || value } this.setHeader(field, value); diff --git a/test/res.set.js b/test/res.set.js index 04511c1c95f..493ca475214 100644 --- a/test/res.set.js +++ b/test/res.set.js @@ -87,6 +87,20 @@ describe('res', function(){ .get('/') .expect(500, /TypeError: Content-Type cannot be set to an Array/, done) }) + + it('should preserve original value when mime.contentType() returns false', function (done) { + var app = express() + + app.use(function (req, res) { + res.set('Content-Type', 'some-custom-type') + res.end() + }); + + request(app) + .get('/') + .expect('Content-Type', 'some-custom-type') + .expect(200, done) + }) }) describe('.set(object)', function(){