diff options
author | James M Snell <jasnell@gmail.com> | 2018-11-03 10:27:18 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-11-21 08:57:56 -0800 |
commit | e94d16daf23bf471ac438860216bfa4c92c86525 (patch) | |
tree | a163aca49ab6c25fd3b4fcbfaad91f4734d4dcbd /test/parallel/test-http2-util-headers-list.js | |
parent | 9379ab3786c0c6a9985f7b32b1c9fe36421b5eaf (diff) | |
download | android-node-v8-e94d16daf23bf471ac438860216bfa4c92c86525.tar.gz android-node-v8-e94d16daf23bf471ac438860216bfa4c92c86525.tar.bz2 android-node-v8-e94d16daf23bf471ac438860216bfa4c92c86525.zip |
http2: throw from mapToHeaders
PR-URL: https://github.com/nodejs/node/pull/24063
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Note: Landed with one collaborator approval after PR
was open for 18 days
Diffstat (limited to 'test/parallel/test-http2-util-headers-list.js')
-rw-r--r-- | test/parallel/test-http2-util-headers-list.js | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 2402e01cbf..2814613df2 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -175,11 +175,11 @@ const { ':statuS': 204, }; - common.expectsError({ + common.expectsError(() => mapToHeaders(headers), { code: 'ERR_HTTP2_HEADER_SINGLE_VALUE', type: TypeError, message: 'Header field ":status" must only have a single value' - })(mapToHeaders(headers)); + }); } // The following are not allowed to have multiple values @@ -224,10 +224,10 @@ const { HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS ].forEach((name) => { const msg = `Header field "${name}" must only have a single value`; - common.expectsError({ + common.expectsError(() => mapToHeaders({ [name]: [1, 2, 3] }), { code: 'ERR_HTTP2_HEADER_SINGLE_VALUE', message: msg - })(mapToHeaders({ [name]: [1, 2, 3] })); + }); }); [ @@ -281,30 +281,32 @@ const { 'Proxy-Connection', 'Keep-Alive' ].forEach((name) => { - common.expectsError({ + common.expectsError(() => mapToHeaders({ [name]: 'abc' }), { code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', message: 'HTTP/1 Connection specific headers are forbidden: ' + `"${name.toLowerCase()}"` - })(mapToHeaders({ [name]: 'abc' })); + }); }); -common.expectsError({ +common.expectsError(() => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }), { code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', message: 'HTTP/1 Connection specific headers are forbidden: ' + `"${HTTP2_HEADER_TE}"` -})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] })); +}); -common.expectsError({ - code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', - name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', - message: 'HTTP/1 Connection specific headers are forbidden: ' + - `"${HTTP2_HEADER_TE}"` -})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] })); +common.expectsError( + () => mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }), { + code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', + name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]', + message: 'HTTP/1 Connection specific headers are forbidden: ' + + `"${HTTP2_HEADER_TE}"` + }); -assert(!(mapToHeaders({ te: 'trailers' }) instanceof Error)); -assert(!(mapToHeaders({ te: ['trailers'] }) instanceof Error)); +// These should not throw +mapToHeaders({ te: 'trailers' }); +mapToHeaders({ te: ['trailers'] }); { |