Skip to content
Myr

res.send() as 204. Closes #419

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 57609c8 · Browse files · 2 files+13 added−0 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+13 added−0 removed

  • tests:+7 added−0 removed
  • other:+6 added−0 removed

2 files+13 added−0 removed

modified:lib/express/response.js+6 added
27 unmodified lines
28 * Send a response with the given `body` and optional `headers` and `status` code.29 *30 * Examples:31 *32 * res.send();33 * res.send(new Buffer('wahoo'));34 * res.send({ some: 'json' });35 * res.send('<p>some html</p>');36 * res.send('Sorry, cant find that', 404);
16 unmodified lines
5354 // Defaults55 status = status || 200;5657 // Allow 0 args as 20458 if (!arguments.length) {59 body = status = 204;60 }6162 // Determine content type63 switch (typeof body) {64 case 'number':65 if (!this.headers['Content-Type']) {
215 unmodified lines
modified:test/response.test.js+7 added
34 unmodified lines
35 36 app.get('/buffer', function(req, res){37 res.send(new Buffer('wahoo!'));38 });39 40 app.get('/noargs', function(req, res, next){41 res.send();42 });4344 assert.response(app,45 { url: '/html' },46 { body: '<p>test</p>', headers: { 'Content-Language': 'en', 'Content-Type': 'text/html; charset=utf-8' }});
11 unmodified lines
58 { body: 'Oh shit!', status: 500, headers: { 'Content-Type': 'text/plain' }});59 assert.response(app,60 { url: '/buffer' },61 { body: 'wahoo!', headers: { 'Content-Type': 'application/octet-stream' }});62 assert.response(app,63 { url: '/noargs' },64 { status: 204 });65 },66 67 'test #contentType()': function(assert){68 var app = express.createServer();
170 unmodified lines