Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions test/res.set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down