Skip to content
Myr

Removed `res.send()` with no args support for 204

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

just use: res.send(204)

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 3d2676d · Browse files · 3 files+4 added−12 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+4 added−12 removed

  • tests:+4 added−7 removed
  • other:+0 added−5 removed

3 files+4 added−12 removed

modified:docs/guide.md-1 removed
858 unmodified lines
859860The _res.send()_ method is a high level response utility allowing you to pass861objects to respond with json, strings for html, Buffer instances, or numbers representing the status code. The following are all valid uses:862863 res.send(); // 204863 res.send(new Buffer('wahoo'));864 res.send({ some: 'json' });865 res.send('<p>some html</p>');866 res.send('Sorry, cant find that', 404);
498 unmodified lines
modified:lib/response.js-4 removed
24 unmodified lines
25 * Send a response with the given `body` and optional `headers` and `status` code.26 *27 * Examples:28 *29 * res.send();29 * res.send(new Buffer('wahoo'));30 * res.send({ some: 'json' });31 * res.send('<p>some html</p>');32 * res.send('Sorry, cant find that', 404);
16 unmodified lines
4950 // default status51 status = status || this.statusCode;5254 // allow 0 args as 20455 if (!arguments.length || undefined === body) body = status = 204;5653 // determine content type54 switch (typeof body) {55 case 'number':56 if (!this.header('Content-Type')) {
401 unmodified lines
modified:test/response.test.js+4 added-7 removed
92 unmodified lines
93 app.get('/buffer', function(req, res){94 res.send(new Buffer('wahoo!'));95 });96 97 app.get('/noargs', function(req, res, next){98 res.send();97 app.get('/204', function(req, res, next){98 res.send(204);99 });100 101 app.get('/undefined', function(req, res, next){102 res.send(undefined);
60 unmodified lines
163 , 'Content-Length': '6'164 }});165 166 assert.response(app,167 { url: '/noargs' },167 { url: '/204' },168 { status: 204 }, function(res){169 assert.equal(undefined, res.headers['content-type']);170 assert.equal(undefined, res.headers['content-length']);171 });172173 assert.response(app,174 { url: '/undefined' },175 { status: 204 }, function(res){176 assert.equal(undefined, res.headers['content-type']);177 assert.equal(undefined, res.headers['content-length']);178 });175 { status: 500 });176177 assert.response(app,178 { url: '/json?callback=test' },179 { body: '{"foo":"bar"}'
591 unmodified lines