test: update non-string header names should throw

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Dhansuhu Uzumaki 2018-04-20 20:31:26 +05:30 committed by Trivikram Kamat
parent 9f97f1044b
commit 1c66a10a0c

View File

@ -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(