Skip to content
Myr

Remove res.send(status, body) signature

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

closes #2942

authored by Mike Tunnicliffe · committed by Douglas Christopher Wilson · parent c319fe2 · Browse files · 4 files+12 added−42 removed
This commit

State

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

Diff stats

4 files+12 added−42 removed

  • tests:+10 added−35 removed
  • other:+2 added−7 removed

4 files+12 added−42 removed

modified:lib/response.js-7 removed
111 unmodified lines
112113 // settings114 var app = this.app;115116 // support res.send(status, body)117 if (arguments.length === 2) {118 deprecate('res.send(status, body): Use res.status(status).send(body) instead');119 this.statusCode = arguments[0];120 chunk = arguments[1];121 }122116 switch (typeof chunk) {117 // string defaulting to html118 case 'string':119 if (!this.get('Content-Type')) {
824 unmodified lines
modified:test/res.format.js+10 added-5 removed
24 unmodified lines
25});2627app1.use(function(err, req, res, next){28 if (!err.types) throw err;29 res.send(err.status, 'Supports: ' + err.types.join(', '));29 res.status(err.status)30 res.send('Supports: ' + err.types.join(', '))31})3233var app2 = express();34
5 unmodified lines
40 });41});4243app2.use(function(err, req, res, next){43 res.send(err.status, 'Supports: ' + err.types.join(', '));44 res.status(err.status)45 res.send('Supports: ' + err.types.join(', '))46})4748var app3 = express();49
14 unmodified lines
64 });65});6667app4.use(function(err, req, res, next){66 res.send(err.status, 'Supports: ' + err.types.join(', '));68 res.status(err.status)69 res.send('Supports: ' + err.types.join(', '))70})7172var app5 = express();73
24 unmodified lines
98 });99 });100101 app.use(function(err, req, res, next){99 res.send(err.status, 'Supports: ' + err.types.join(', '));102 res.status(err.status)103 res.send('Supports: ' + err.types.join(', '))104 });105106 test(app);107 })
30 unmodified lines
138 });139 });140141 router.use(function(err, req, res, next){138 res.send(err.status, 'Supports: ' + err.types.join(', '));142 res.status(err.status)143 res.send('Supports: ' + err.types.join(', '))144 })145146 app.use(router)147
70 unmodified lines
modified:test/res.send.js-30 removed
46 unmodified lines
47 .expect(200, '', done);48 })49 })5051 describe('.send(code, body)', function(){52 it('should set .statusCode and body', function(done){53 var app = express();5455 app.use(function(req, res){56 res.send(201, 'Created :)');57 });5859 request(app)60 .get('/')61 .expect('Created :)')62 .expect(201, done);63 })64 })6566 describe('.send(code, number)', function(){67 it('should send number as json', function(done){68 var app = express();6970 app.use(function(req, res){71 res.send(200, 0.123);72 });7374 request(app)75 .get('/')76 .expect('Content-Type', 'application/json; charset=utf-8')77 .expect(200, '0.123', done);78 })79 })8051 describe('.send(Number)', function(){52 it('should send as application/json', function(done){53 var app = express();54
450 unmodified lines
modified:History.md+2 added
1 unmodified line
2===34This incorporates all changes after 4.15.2 up to 4.15.4.56 * remove:7 - `res.send(status, body)` signature - use `res.status(status).send(body)`8 * deps: router@~1.3.19 - deps: debug@2.6.810115.0.0-alpha.5 / 2017-03-06
3366 unmodified lines