From 60290647560025e43495bd60f5ef054973f014e3 Mon Sep 17 00:00:00 2001 From: Bernie Stern Date: Mon, 6 Nov 2017 07:17:43 -0500 Subject: [PATCH] HTTP/2 has no status message (#1048) (#1049) --- lib/response.js | 2 +- test/response/status.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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', () => {