set content-type for redirect when accpect plain
This commit is contained in:
parent
b854d00363
commit
57eb6a10df
2 changed files with 14 additions and 0 deletions
|
@ -257,6 +257,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// text
|
// text
|
||||||
|
this.type = 'text/plain; charset=utf-8';
|
||||||
this.body = 'Redirecting to ' + url + '.';
|
this.body = 'Redirecting to ' + url + '.';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,19 @@ describe('ctx.redirect(url)', function(){
|
||||||
ctx.body.should.equal('Redirecting to ' + url + '.');
|
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) {
|
function escape(html) {
|
||||||
|
|
Loading…
Reference in a new issue