diff --git a/lib/response.js b/lib/response.js index 5046395..6c663a7 100644 --- a/lib/response.js +++ b/lib/response.js @@ -85,7 +85,7 @@ module.exports = { assert(!this.res.headersSent, 'headers have already been sent'); this._explicitStatus = true; this.res.statusCode = code; - this.res.statusMessage = statuses[code]; + if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code]; if (this.body && statuses.empty[code]) this.body = null; }, diff --git a/test/response/status.js b/test/response/status.js index 6b7eb07..9b74612 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -44,6 +44,17 @@ describe('res.status=', () => { assert.doesNotThrow(() => response().status = 700); }); }); + + describe('and HTTP/2', () => { + it('should not set the status message', () => { + const res = response({ + 'httpVersionMajor': 2, + 'httpVersion': '2.0' + }); + res.status = 200; + assert(!res.res.statusMessage); + }); + }); }); describe('when a status string', () => {