fix res.type= for unknown types

because we changed from mime to mime-types. ideally, we should just not
set the content-type, but this way it’s backwards compatible. we can
change it later.
master
Jonathan Ong 2014-06-06 16:26:03 -07:00
parent 90c528c5e8
commit 1a32ecac31
2 changed files with 10 additions and 1 deletions

View File

@ -274,7 +274,7 @@ module.exports = {
*/
set type(type) {
this.set('Content-Type', getType(type));
this.set('Content-Type', getType(type) || 'application/octet-stream');
},
/**

View File

@ -38,6 +38,15 @@ describe('ctx.type=', function(){
ctx.response.header['content-type'].should.equal('text/html; charset=foo');
})
})
describe('with an unknown extension', function(){
it('should default to application/octet-stream',function(){
var ctx = context();
ctx.type = 'asdf';
ctx.type.should.equal('application/octet-stream');
ctx.response.header['content-type'].should.equal('application/octet-stream');
})
})
})
describe('ctx.type', function(){