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 <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
dhanushuUzumaki authored and jasnell committed Apr 23, 2018
1 parent f274e69 commit bb3ead8
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 bb3ead8

Please sign in to comment.