diff --git a/lib/response.js b/lib/response.js index 6c663a756..acd198d81 100644 --- a/lib/response.js +++ b/lib/response.js @@ -178,7 +178,7 @@ module.exports = { // json this.remove('Content-Length'); - this.type = 'json'; + if (setType) this.type = 'json'; }, /** diff --git a/test/response/body.js b/test/response/body.js index 1dfcac55e..c2dfadbdf 100644 --- a/test/response/body.js +++ b/test/response/body.js @@ -15,14 +15,14 @@ describe('res.body=', () => { }); describe('when body is an object', () => { - it('should override as json', () => { + it('should not override as json', () => { const res = response(); res.body = 'hey'; assert.equal('text/html; charset=utf-8', res.header['content-type']); res.body = { foo: 'bar' }; - assert.equal('application/json; charset=utf-8', res.header['content-type']); + assert.equal('text/html; charset=utf-8', res.header['content-type']); }); });