Skip to content
Myr

Added `res.send(body, status)` support back for backwards compat

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

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 362c96c · Browse files · 2 files+28 added−4 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+28 added−4 removed

  • tests:+19 added−1 removed
  • other:+9 added−3 removed

2 files+28 added−4 removed

modified:lib/response.js+9 added-3 removed
83 unmodified lines
84 , len;8586 // allow status / body87 if (2 == arguments.length) {88 // res.send(body, status) backwards compat89 if ('number' != typeof body && 'number' == typeof arguments[1]) {90 this.statusCode = arguments[1];91 } else {88 this.statusCode = body;89 body = arguments[1];92 this.statusCode = body;93 body = arguments[1];94 }95 }91 969798 // convert string objects to primitives99 if (body instanceof String) body = body.toString();100101 switch (typeof body) {
580 unmodified lines
modified:test/res.send.js+19 added-1 removed
70 unmodified lines
71 done();72 })73 })74 })75 7576 describe('.send(body, code)', function(){77 it('should be supported for backwards compat', function(done){78 var app = express();7980 app.use(function(req, res){81 res.send('Bad!', 400);82 });8384 request(app)85 .get('/')86 .end(function(res){87 res.body.should.equal('Bad!');88 res.statusCode.should.equal(400);89 done();90 })91 })92 })9394 describe('.send(String)', function(){95 it('should send as html', function(done){96 var app = express();97
256 unmodified lines