Skip to content

Commit 5028e5f

Browse files
committed
Allow 0, false, and null as json body #686
0, false, and null are all valid body contents of a request, however currently only an empty body is returned in these cases. For Example: response.json(200, true); - currently returns: 200 OK true - however false doesn't return a body: response.json(200, false); 200 OK Change allows false to also return: response.json(200, false); 200 OK false
1 parent d42c769 commit 5028e5f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Response.prototype.send = function send(code, body, headers) {
227227
log.trace({res: self}, 'response sent');
228228
}
229229

230-
if (body) {
230+
if (body !== undefined) {
231231
var ret = this.format(body, _cb);
232232
if (!(ret instanceof Response)) {
233233
_cb(null, ret);

0 commit comments

Comments
 (0)