set content-type for redirect when accpect plain

master
dead_horse 2014-11-28 01:01:15 +08:00 committed by Jonathan Ong
parent b854d00363
commit 57eb6a10df
2 changed files with 14 additions and 0 deletions

View File

@ -257,6 +257,7 @@ module.exports = {
}
// text
this.type = 'text/plain; charset=utf-8';
this.body = 'Redirecting to ' + url + '.';
},

View File

@ -91,6 +91,19 @@ describe('ctx.redirect(url)', function(){
ctx.body.should.equal('Redirecting to ' + url + '.');
})
})
describe('when content-type was present', function(){
it('should overwrite content-type', function() {
var ctx = context();
ctx.body = {};
var url = 'http://google.com';
ctx.header.accept = 'text/plain';
ctx.redirect('http://google.com');
ctx.status.should.equal(302);
ctx.body.should.equal('Redirecting to ' + url + '.');
ctx.type.should.equal('text/plain');
})
})
})
function escape(html) {