diff --git a/lib/response.js b/lib/response.js index c01526e1c..fa63a3d42 100644 --- a/lib/response.js +++ b/lib/response.js @@ -84,7 +84,7 @@ module.exports = { if (this.headerSent) return; assert('number' == typeof code, 'status code must be a number'); - assert(statuses[code], `invalid status code: ${code}`); + assert(/[0-9]{3}/.test(code), `invalid status code: ${code}`); this._explicitStatus = true; this.res.statusCode = code; if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code]; diff --git a/test/response/status.js b/test/response/status.js index 63e2ff687..af3394885 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -24,8 +24,8 @@ describe('res.status=', () => { describe('and invalid', () => { it('should throw', () => { assert.throws(() => { - response().status = 999; - }, /invalid status code: 999/); + response().status = 99; + }, /invalid status code: 99/); }); });