Skip to content

Commit

Permalink
Remove res.send(body, status) signature
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Nov 7, 2014
1 parent 085a296 commit e66625b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
2 changes: 2 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
5.x
===

* remove:
- `res.send(body, status)` signature - use `res.send(status, body)`
* change:
- `req.host` now returns host (`hostname:port`) - use `req.hostname` for only hostname

Expand Down
14 changes: 4 additions & 10 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,11 @@ res.send = function send(body) {
// settings
var app = this.app;

// allow status / body
// support res.send(status, body)
if (arguments.length === 2) {
// res.send(body, status) backwards compat
if (typeof arguments[0] !== 'number' && typeof arguments[1] === 'number') {
deprecate('res.send(body, status): Use res.status(status).send(body) instead');
this.statusCode = arguments[1];
} else {
deprecate('res.send(status, body): Use res.status(status).send(body) instead');
this.statusCode = arguments[0];
chunk = arguments[1];
}
deprecate('res.send(status, body): Use res.status(status).send(body) instead');
this.statusCode = arguments[0];
chunk = arguments[1];
}

// disambiguate res.send(status) and res.send(status, num)
Expand Down
15 changes: 0 additions & 15 deletions test/res.send.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ describe('res', function(){
})
})

describe('.send(body, code)', function(){
it('should be supported for backwards compat', function(done){
var app = express();

app.use(function(req, res){
res.send('Bad!', 400);
});

request(app)
.get('/')
.expect('Bad!')
.expect(400, done);
})
})

describe('.send(code, number)', function(){
it('should send number as json', function(done){
var app = express();
Expand Down

0 comments on commit e66625b

Please sign in to comment.