Skip to content

Commit

Permalink
test: update non-string header names should throw
Browse files Browse the repository at this point in the history
PR-URL: #20172
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
dhanushuUzumaki authored and trivikr committed Apr 23, 2018
1 parent 9f97f10 commit 1c66a10
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/parallel/test-http-write-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ const s = http.createServer(common.mustCall((req, res) => {
res.setHeader('test', '1');

// toLowerCase() is used on the name argument, so it must be a string.
let threw = false;
try {
res.setHeader(0xf00, 'bar');
} catch (e) {
assert.ok(e instanceof TypeError);
threw = true;
}
assert.ok(threw, 'Non-string names should throw');
// Non-String header names should throw
common.expectsError(
() => res.setHeader(0xf00, 'bar'),
{
code: 'ERR_INVALID_HTTP_TOKEN',
type: TypeError,
message: 'Header name must be a valid HTTP token ["3840"]'
}
);

// undefined value should throw, via 979d0ca8
common.expectsError(
Expand Down

0 comments on commit 1c66a10

Please sign in to comment.