summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2018-11-29 14:33:20 +0100
committerRich Trott <rtrott@gmail.com>2018-12-02 21:39:45 -0800
commit32fed93aee30be5401ff99cfde3360ce037e294a (patch)
treee9a0cac22706369cfc4a0a6cd0c95fb860da56ae /test
parent175164e5d12829b46f91137a01dac72f236a37be (diff)
downloadandroid-node-v8-32fed93aee30be5401ff99cfde3360ce037e294a.tar.gz
android-node-v8-32fed93aee30be5401ff99cfde3360ce037e294a.tar.bz2
android-node-v8-32fed93aee30be5401ff99cfde3360ce037e294a.zip
http2: make compat writeHead not crash if the stream is destroyed
Fixes: https://github.com/nodejs/node/issues/24470 PR-URL: https://github.com/nodejs/node/pull/24723 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http2-compat-write-head-destroyed.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-http2-compat-write-head-destroyed.js b/test/parallel/test-http2-compat-write-head-destroyed.js
new file mode 100644
index 0000000000..4576119ee7
--- /dev/null
+++ b/test/parallel/test-http2-compat-write-head-destroyed.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+ common.skip('missing crypto');
+const http2 = require('http2');
+
+// Check that writeHead, write and end do not crash in compatibility mode
+
+const server = http2.createServer(common.mustCall((req, res) => {
+ // destroy the stream first
+ req.stream.destroy();
+
+ res.writeHead(200);
+ res.write('hello ');
+ res.end('world');
+}));
+
+server.listen(0, common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${server.address().port}`);
+
+ const req = client.request();
+ req.on('response', common.mustNotCall());
+ req.on('close', common.mustCall((arg) => {
+ client.close();
+ server.close();
+ }));
+ req.resume();
+}));