Skip to content

Commit e66625b

Browse files
committed
Remove res.send(body, status) signature
1 parent 085a296 commit e66625b

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

Diff for: History.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
5.x
22
===
33

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

Diff for: lib/response.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,11 @@ res.send = function send(body) {
8989
// settings
9090
var app = this.app;
9191

92-
// allow status / body
92+
// support res.send(status, body)
9393
if (arguments.length === 2) {
94-
// res.send(body, status) backwards compat
95-
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];
102-
}
94+
deprecate('res.send(status, body): Use res.status(status).send(body) instead');
95+
this.statusCode = arguments[0];
96+
chunk = arguments[1];
10397
}
10498

10599
// disambiguate res.send(status) and res.send(status, num)

Diff for: test/res.send.js

-15
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,6 @@ describe('res', function(){
6666
})
6767
})
6868

69-
describe('.send(body, code)', function(){
70-
it('should be supported for backwards compat', function(done){
71-
var app = express();
72-
73-
app.use(function(req, res){
74-
res.send('Bad!', 400);
75-
});
76-
77-
request(app)
78-
.get('/')
79-
.expect('Bad!')
80-
.expect(400, done);
81-
})
82-
})
83-
8469
describe('.send(code, number)', function(){
8570
it('should send number as json', function(done){
8671
var app = express();

0 commit comments

Comments
 (0)