Skip to content

Commit

Permalink
test: increase coverage for http2 response headers
Browse files Browse the repository at this point in the history
Expanded an existing test for setting pseudo-headers on response to
include all pseudo-headers, not just :status.

Refs: nodejs#14985
  • Loading branch information
apapirovski committed Aug 25, 2017
1 parent 7efb8f7 commit 3a7b684
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/parallel/test-http2-compat-serverresponse-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ server.listen(0, common.mustCall(function() {
response.removeHeader(denormalised);
assert.strictEqual(response.hasHeader(denormalised), false);

assert.throws(function() {
response.setHeader(':status', 'foobar');
}, common.expectsError({
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED',
type: Error,
message: 'Cannot set HTTP/2 pseudo-headers'
}));
[
':status',
':method',
':path',
':authority',
':scheme'
].forEach((header) => assert.throws(
() => response.setHeader(header, 'foobar'),
common.expectsError({
code: 'ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED',
type: Error,
message: 'Cannot set HTTP/2 pseudo-headers'
})
));
assert.throws(function() {
response.setHeader(real, null);
}, common.expectsError({
Expand Down

0 comments on commit 3a7b684

Please sign in to comment.