diff --git a/lib/response.js b/lib/response.js index c01526e..f9b33d5 100644 --- a/lib/response.js +++ b/lib/response.js @@ -83,8 +83,8 @@ module.exports = { set status(code) { if (this.headerSent) return; - assert('number' == typeof code, 'status code must be a number'); - assert(statuses[code], `invalid status code: ${code}`); + assert(Number.isInteger(code), 'status code must be a number'); + assert(code >= 100 && code <= 999, `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 63e2ff6..af33948 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/); }); });