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
Provenance
- Commit
e3bd14d- Tree
1e26cb3- Author
Mike Tunnicliffe <mike.tunnicliffe@uk.ibm.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
c319fe2
4 files changed+12 added−42 removed
modified:lib/response.js-7 removed
111 unmodified lines112 113 // settings114 var app = this.app;115 116- // 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- }122-116 switch (typeof chunk) {117 // string defaulting to html118 case 'string':119 if (!this.get('Content-Type')) {824 unmodified linesmodified:test/res.format.js+10 added-5 removed
24 unmodified lines25 });26 27 app1.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 })32 33 var app2 = express();34 5 unmodified lines40 });41 });42 43 app2.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 })47 48 var app3 = express();49 14 unmodified lines64 });65 });66 67 app4.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 })71 72 var app5 = express();73 24 unmodified lines98 });99 });100 101 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 });105 106 test(app);107 })30 unmodified lines138 });139 });140 141 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 })145 146 app.use(router)147 70 unmodified linesmodified:test/res.send.js-30 removed
46 unmodified lines47 .expect(200, '', done);48 })49 })50 51- describe('.send(code, body)', function(){52- it('should set .statusCode and body', function(done){53- var app = express();54-55- app.use(function(req, res){56- res.send(201, 'Created :)');57- });58-59- request(app)60- .get('/')61- .expect('Created :)')62- .expect(201, done);63- })64- })65-66- describe('.send(code, number)', function(){67- it('should send number as json', function(done){68- var app = express();69-70- app.use(function(req, res){71- res.send(200, 0.123);72- });73-74- request(app)75- .get('/')76- .expect('Content-Type', 'application/json; charset=utf-8')77- .expect(200, '0.123', done);78- })79- })80-51 describe('.send(Number)', function(){52 it('should send as application/json', function(done){53 var app = express();54 450 unmodified linesmodified:History.md+2 added
1 unmodified line2 ===3 4 This incorporates all changes after 4.15.2 up to 4.15.4.5 6+ * remove:7+ - `res.send(status, body)` signature - use `res.status(status).send(body)`8 * deps: router@~1.3.19 - deps: debug@2.6.810 11 5.0.0-alpha.5 / 2017-03-063366 unmodified lines