Skip to content

Commit bb3ead8

Browse files
dhanushuUzumakijasnell
authored andcommitted
test: update non-string header names should throw
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>
1 parent f274e69 commit bb3ead8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/parallel/test-http-write-head.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ const s = http.createServer(common.mustCall((req, res) => {
3131
res.setHeader('test', '1');
3232

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

4344
// undefined value should throw, via 979d0ca8
4445
common.expectsError(

0 commit comments

Comments
 (0)