summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-respond-errors.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2018-04-11 16:11:35 -0700
committerJames M Snell <jasnell@gmail.com>2018-04-16 09:53:32 -0700
commit237aa7e9ae850bbaf39563b368bc617468f2136d (patch)
tree35bae554a67816fe25069356db3703bceb98214c /test/parallel/test-http2-respond-errors.js
parent2e76b175edfecf1d667b2e3bde907f1120f5da49 (diff)
downloadandroid-node-v8-237aa7e9ae850bbaf39563b368bc617468f2136d.tar.gz
android-node-v8-237aa7e9ae850bbaf39563b368bc617468f2136d.tar.bz2
android-node-v8-237aa7e9ae850bbaf39563b368bc617468f2136d.zip
http2: refactor how trailers are done
Rather than an option, introduce a method and an event... ```js server.on('stream', (stream) => { stream.respond(undefined, { waitForTrailers: true }); stream.on('wantTrailers', () => { stream.sendTrailers({ abc: 'xyz'}); }); stream.end('hello world'); }); ``` This is a breaking change in the API such that the prior `options.getTrailers` is no longer supported at all. Ordinarily this would be semver-major and require a deprecation but the http2 stuff is still experimental. PR-URL: https://github.com/nodejs/node/pull/19959 Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-respond-errors.js')
-rw-r--r--test/parallel/test-http2-respond-errors.js37
1 files changed, 1 insertions, 36 deletions
diff --git a/test/parallel/test-http2-respond-errors.js b/test/parallel/test-http2-respond-errors.js
index 656a27df26..fa8a98b83f 100644
--- a/test/parallel/test-http2-respond-errors.js
+++ b/test/parallel/test-http2-respond-errors.js
@@ -7,48 +7,13 @@ if (!common.hasCrypto)
const http2 = require('http2');
const { Http2Stream } = process.binding('http2');
-const types = {
- boolean: true,
- function: () => {},
- number: 1,
- object: {},
- array: [],
- null: null,
- symbol: Symbol('test')
-};
-
const server = http2.createServer();
Http2Stream.prototype.respond = () => 1;
server.on('stream', common.mustCall((stream) => {
- // Check for all possible TypeError triggers on options.getTrailers
- Object.entries(types).forEach(([type, value]) => {
- if (type === 'function') {
- return;
- }
-
- common.expectsError(
- () => stream.respond({
- 'content-type': 'text/plain'
- }, {
- ['getTrailers']: value
- }),
- {
- type: TypeError,
- code: 'ERR_INVALID_OPT_VALUE',
- message: `The value "${String(value)}" is invalid ` +
- 'for option "getTrailers"'
- }
- );
- });
-
// Send headers
- stream.respond({
- 'content-type': 'text/plain'
- }, {
- ['getTrailers']: () => common.mustCall()
- });
+ stream.respond({ 'content-type': 'text/plain' });
// Should throw if headers already sent
common.expectsError(