summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-compat-serverresponse-createpushresponse.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-compat-serverresponse-createpushresponse.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-compat-serverresponse-createpushresponse.js')
-rw-r--r--test/parallel/test-http2-compat-serverresponse-createpushresponse.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/parallel/test-http2-compat-serverresponse-createpushresponse.js b/test/parallel/test-http2-compat-serverresponse-createpushresponse.js
index e0ce51bfc7..1992d41af6 100644
--- a/test/parallel/test-http2-compat-serverresponse-createpushresponse.js
+++ b/test/parallel/test-http2-compat-serverresponse-createpushresponse.js
@@ -28,6 +28,15 @@ const server = h2.createServer((request, response) => {
}
);
+ response.stream.on('close', () => {
+ response.createPushResponse({
+ ':path': '/pushed',
+ ':method': 'GET'
+ }, common.mustCall((error) => {
+ assert.strictEqual(error.code, 'ERR_HTTP2_INVALID_STREAM');
+ }));
+ });
+
response.createPushResponse({
':path': '/pushed',
':method': 'GET'
@@ -36,16 +45,6 @@ const server = h2.createServer((request, response) => {
assert.strictEqual(push.stream.id % 2, 0);
push.end(pushExpect);
response.end();
-
- // wait for a tick, so the stream is actually closed
- setImmediate(function() {
- response.createPushResponse({
- ':path': '/pushed',
- ':method': 'GET'
- }, common.mustCall((error) => {
- assert.strictEqual(error.code, 'ERR_HTTP2_INVALID_STREAM');
- }));
- });
}));
});