Skip to content
Myr

Remove res.send(body, status) signature

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

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 085a296 · Browse files · 3 files+6 added−25 removed
This commit

State

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

Diff stats

3 files+6 added−25 removed

  • tests:+0 added−15 removed
  • other:+6 added−10 removed

3 files+6 added−25 removed

modified:lib/response.js+4 added-10 removed
87 unmodified lines
8889 // settings90 var app = this.app;9192 // allow status / body92 // support res.send(status, body)93 if (arguments.length === 2) {94 // res.send(body, status) backwards compat95 if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') {96 deprecate('res.send(body, status): Use res.status(status).send(body) instead');97 this.statusCode = arguments[1];98 } else {99 deprecate('res.send(status, body): Use res.status(status).send(body) instead');100 this.statusCode = arguments[0];101 chunk = arguments[1];94 deprecate('res.send(status, body): Use res.status(status).send(body) instead');95 this.statusCode = arguments[0];96 chunk = arguments[1];102 }97 }9899 // disambiguate res.send(status) and res.send(status, num)100 if (typeof chunk === 'number' && arguments.length === 1) {
865 unmodified lines
modified:test/res.send.js-15 removed
64 unmodified lines
65 .expect(201, done);66 })67 })6869 describe('.send(body, code)', function(){70 it('should be supported for backwards compat', function(done){71 var app = express();7273 app.use(function(req, res){74 res.send('Bad!', 400);75 });7677 request(app)78 .get('/')79 .expect('Bad!')80 .expect(400, done);81 })82 })8369 describe('.send(code, number)', function(){70 it('should send number as json', function(done){71 var app = express();72
466 unmodified lines
modified:History.md+2 added
15.x2===34 * remove:5 - `res.send(body, status)` signature - use `res.send(status, body)`6 * change:7 - `req.host` now returns host (`hostname:port`) - use `req.hostname` for only hostname894.10.1 / 2014-10-28
2449 unmodified lines