forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: nodejs#24456 PR-URL: nodejs#24631 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
Showing
3 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters