diff options
author | Rich Trott <rtrott@gmail.com> | 2018-11-24 11:27:15 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-24 23:36:08 -0800 |
commit | 8c0aa84f854d29ef44485d52c8bddba7a3ce77d0 (patch) | |
tree | 1c734f8df317812c07cf3fd5707660aea0d9e186 /test/parallel/test-stream-pipeline-http2.js | |
parent | 824f16c8610b31ce06e4b6ff6927eb0df2da1953 (diff) | |
download | android-node-v8-8c0aa84f854d29ef44485d52c8bddba7a3ce77d0.tar.gz android-node-v8-8c0aa84f854d29ef44485d52c8bddba7a3ce77d0.tar.bz2 android-node-v8-8c0aa84f854d29ef44485d52c8bddba7a3ce77d0.zip |
test: split out http2 from test-stream-pipeline
Splitting out the http2 portion of the test has a few benfits:
* We don't skip the rest of the tests if `node` is compiled without
crypto.
* We can find out if the http2 portion of the test is responsible for
the timeouts reported in issue 24456.
Refs: https://github.com/nodejs/node/issues/24456
PR-URL: https://github.com/nodejs/node/pull/24631
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-stream-pipeline-http2.js')
-rw-r--r-- | test/parallel/test-stream-pipeline-http2.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/parallel/test-stream-pipeline-http2.js b/test/parallel/test-stream-pipeline-http2.js new file mode 100644 index 0000000000..d7ff08888a --- /dev/null +++ b/test/parallel/test-stream-pipeline-http2.js @@ -0,0 +1,36 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const { Readable, pipeline } = require('stream'); +const http2 = require('http2'); + +{ + const server = http2.createServer((req, res) => { + pipeline(req, res, common.mustCall()); + }); + + server.listen(0, () => { + const url = `http://localhost:${server.address().port}`; + const client = http2.connect(url); + const req = client.request({ ':method': 'POST' }); + + const rs = new Readable({ + read() { + rs.push('hello'); + } + }); + + pipeline(rs, req, common.mustCall((err) => { + server.close(); + client.close(); + })); + + let cnt = 10; + req.on('data', (data) => { + cnt--; + if (cnt === 0) rs.destroy(); + }); + }); +} |