Skip to content
Myr

Remove res.send(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 0fc4f07 · Browse files · 6 files+21 added−32 removed
This commit

State

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

Diff stats

6 files+21 added−32 removed

  • tests:+16 added−16 removed
  • other:+5 added−16 removed

6 files+21 added−32 removed

modified:examples/cors/index.js+2 added-2 removed
modified:examples/search/index.js+2 added-2 removed
modified:lib/response.js-12 removed
94 unmodified lines
95 this.statusCode = arguments[0];96 chunk = arguments[1];97 }9899 // disambiguate res.send(status) and res.send(status, num)100 if (typeof chunk === 'number' && arguments.length === 1) {101 // res.send(status) will set status message as text string102 if (!this.get('Content-Type')) {103 this.type('txt');104 }105106 deprecate('res.send(status): Use res.sendStatus(status) instead');107 this.statusCode = chunk;108 chunk = http.STATUS_CODES[chunk];109 }11099 switch (typeof chunk) {100 // string defaulting to html101 case 'string':102 if (!this.get('Content-Type')) {
767 unmodified lines
modified:test/app.routes.error.js+1 added-1 removed
modified:test/res.send.js+15 added-15 removed
34 unmodified lines
35 });36 })37 })3839 describe('.send(code)', function(){40 it('should set .statusCode', function(done){39 describe('.send(code, body)', function(){40 it('should set .statusCode and body', function(done){41 var app = express();4243 app.use(function(req, res){44 res.send(201).should.equal(res);44 res.send(201, 'Created :)');45 });4647 request(app)48 .get('/')49 .expect('Created')49 .expect('Created :)')50 .expect(201, done);51 })52 })5354 describe('.send(code, body)', function(){55 it('should set .statusCode and body', function(done){54 describe('.send(code, number)', function(){55 it('should send number as json', function(done){56 var app = express();5758 app.use(function(req, res){59 res.send(201, 'Created :)');59 res.send(200, 0.123);60 });6162 request(app)63 .get('/')64 .expect('Created :)')65 .expect(201, done);64 .expect('Content-Type', 'application/json; charset=utf-8')65 .expect(200, '0.123', done);66 })67 })6869 describe('.send(code, number)', function(){70 it('should send number as json', function(done){69 describe('.send(Number)', function(){70 it('should send as application/json', function(done){71 var app = express();7273 app.use(function(req, res){74 res.send(200, 0.123);74 res.send(1000);75 });7677 request(app)78 .get('/')79 .expect('Content-Type', 'application/json; charset=utf-8')80 .expect(200, '0.123', done);80 .expect(200, '1000', done)81 })82 })8384 describe('.send(String)', function(){
313 unmodified lines
398 var app = express();399400 app.use(function(req, res){401 res.set('etag', '"asdf"');402 res.send(200);402 res.send('hello!');403 });404405 app.enable('etag');406
45 unmodified lines
452 app.disable('etag');453454 app.use(function(req, res){455 res.set('etag', '"asdf"');456 res.send(200);456 res.send('hello!');457 });458459 request(app)460 .get('/')
78 unmodified lines
modified:History.md+1 added
7 unmodified lines
8 - `req.acceptsLanguage` - use `req.acceptsLanguages`9 - `res.json(obj, status)` signature - use `res.json(status, obj)`10 - `res.jsonp(obj, status)` signature - use `res.jsonp(status, obj)`11 - `res.send(body, status)` signature - use `res.send(status, body)`12 - `res.send(status)` signature - use `res.sendStatus(status)`13 - `res.sendfile` - use `res.sendFile` instead14 - `express.query` middleware15 * change:16 - `req.host` now returns host (`hostname:port`) - use `req.hostname` for only hostname
2454 unmodified lines