Skip to content

Commit

Permalink
HTTP/2 has no status message (#1048) (#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
BernzSed authored and jonathanong committed Nov 6, 2017
1 parent 18e4faf commit 6029064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/response.js
Expand Up @@ -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;
},

Expand Down
11 changes: 11 additions & 0 deletions test/response/status.js
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 6029064

Please sign in to comment.