diff --git a/lib/response.js b/lib/response.js index 0b9c355d4..0d3700c43 100644 --- a/lib/response.js +++ b/lib/response.js @@ -353,7 +353,9 @@ function patch(Response) { // Check to see if the next argument is a body if ( typeof arguments[index] === 'object' || - typeof arguments[index] === 'string' + typeof arguments[index] === 'string' || + typeof arguments[index] === 'boolean' || + typeof arguments[index] === 'number' ) { body = arguments[index++]; } diff --git a/test/response.test.js b/test/response.test.js index 0876228fe..f398276bd 100644 --- a/test/response.test.js +++ b/test/response.test.js @@ -636,3 +636,42 @@ test('should support multiple set-cookie headers', function(t) { t.end(); }); }); + +test('GH-1607: should send bools with explicit status code', function(t) { + SERVER.get('/bool/:value', function(req, res, next) { + res.send(200, req.params.value === 'true' ? true : false); + return next(); + }); + + STRING_CLIENT.get(join(LOCALHOST, '/bool/false'), + function(err, req, res, data) { + t.equal(data, 'false'); + + STRING_CLIENT.get(join(LOCALHOST, '/bool/true'), + function(err, req, res, data) { + t.equal(data, 'true'); + t.end(); + }); + }); +}); + +test('GH-1607: should send numbers with explicit status code', function(t) { + SERVER.get('/zero', function(req, res, next) { + res.send(200, 0); + return next(); + }); + + SERVER.get('/one', function(req, res, next) { + res.send(200, 1); + return next(); + }); + + STRING_CLIENT.get(join(LOCALHOST, '/zero'), function(err, req, res, data) { + t.equal(data, '0'); + STRING_CLIENT.get(join(LOCALHOST, '/one'), + function(err, req, res, data) { + t.equal(data, '1'); + t.end(); + }); + }); +});