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.
This commit is contained in:
parent
90c528c5e8
commit
1a32ecac31
2 changed files with 10 additions and 1 deletions
|
@ -274,7 +274,7 @@ module.exports = {
|
|||
*/
|
||||
|
||||
set type(type) {
|
||||
this.set('Content-Type', getType(type));
|
||||
this.set('Content-Type', getType(type) || 'application/octet-stream');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in a new issue