Skip to content
Permalink
Browse files

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>
  • Loading branch information...
dhanushuUzumaki authored and trivikr committed Apr 20, 2018
1 parent 9f97f10 commit 1c66a10a0c619568db77d7e05d11911eff474d70
Showing with 9 additions and 8 deletions.
  1. +9 −8 test/parallel/test-http-write-head.js
@@ -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(

0 comments on commit 1c66a10

Please sign in to comment.
You can’t perform that action at this time.