Keep previous Content-Type for res.jsonp

closes #2094
This commit is contained in:
Alberto Leal 2014-05-02 15:33:09 -03:00 committed by Douglas Christopher Wilson
parent 5c3852b91c
commit be997fd654
2 changed files with 19 additions and 1 deletions

View File

@ -230,7 +230,7 @@ res.jsonp = function(obj){
var callback = this.req.query[app.get('jsonp callback name')];
// content-type
this.set('Content-Type', 'application/json');
this.get('Content-Type') || this.set('Content-Type', 'application/json');
// jsonp
if (callback) {

View File

@ -242,4 +242,22 @@ describe('res', function(){
})
})
})
it('should not override previous Content-Types', function(done){
var app = express();
app.get('/', function(req, res){
res.type('application/vnd.example+json');
res.jsonp({ hello: 'world' });
});
request(app)
.get('/')
.end(function(err, res){
res.statusCode.should.equal(200);
res.headers.should.have.property('content-type', 'application/vnd.example+json');
res.text.should.equal('{"hello":"world"}');
done();
})
})
})