Skip to content
Myr

Keep previous Content-Type for res.jsonp

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #2094

authored by Alberto Leal · committed by Douglas Christopher Wilson · parent 5c3852b · Browse files · 2 files+19 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+19 added−1 removed

  • tests:+18 added−0 removed
  • other:+1 added−1 removed

2 files+19 added−1 removed

modified:lib/response.js+1 added-1 removed
228 unmodified lines
229 .replace(/\u2029/g, '\\u2029');230 var callback = this.req.query[app.get('jsonp callback name')];231232 // content-type233 this.set('Content-Type', 'application/json');233 this.get('Content-Type') || this.set('Content-Type', 'application/json');234235 // jsonp236 if (callback) {237 if (Array.isArray(callback)) callback = callback[0];
543 unmodified lines
modified:test/res.jsonp.js+18 added
240 unmodified lines
241 done();242 })243 })244 })245246 it('should not override previous Content-Types', function(done){247 var app = express();248249 app.get('/', function(req, res){250 res.type('application/vnd.example+json');251 res.jsonp({ hello: 'world' });252 });253254 request(app)255 .get('/')256 .end(function(err, res){257 res.statusCode.should.equal(200);258 res.headers.should.have.property('content-type', 'application/vnd.example+json');259 res.text.should.equal('{"hello":"world"}');260 done();261 })262 })263})