diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-06-25 18:46:33 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-06-30 15:52:54 +0200 |
commit | 64a3fadf7192485197b9695b7bb2165c7e7d762d (patch) | |
tree | c226390642b88585eebcb38899e7afb1f2fda75c /test/parallel/test-http2-pipe-named-pipe.js | |
parent | a078521a6a9cede03208216d58d5af13e8406cbe (diff) | |
download | android-node-v8-64a3fadf7192485197b9695b7bb2165c7e7d762d.tar.gz android-node-v8-64a3fadf7192485197b9695b7bb2165c7e7d762d.tar.bz2 android-node-v8-64a3fadf7192485197b9695b7bb2165c7e7d762d.zip |
src: remove StreamBase::kFlagHasWritev
Since libuv 1.21.0, pipes on Windows support `writev` on the
libuv side.
This allows for some simplification, and makes the `StreamBase`
API more uniform (multi-buffer `Write()` is always supported now,
including when used by other non-JS consumers like HTTP/2).
PR-URL: https://github.com/nodejs/node/pull/21527
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-pipe-named-pipe.js')
-rw-r--r-- | test/parallel/test-http2-pipe-named-pipe.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js new file mode 100644 index 0000000000..49fc142961 --- /dev/null +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -0,0 +1,52 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const fixtures = require('../common/fixtures'); +const assert = require('assert'); +const http2 = require('http2'); +const fs = require('fs'); +const net = require('net'); +const path = require('path'); + +// HTTP/2 servers can listen on a named pipe. + +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); +const loc = fixtures.path('url-tests.js'); +const fn = path.join(tmpdir.path, 'http2-url-tests.js'); + +const server = http2.createServer(); + +server.on('stream', common.mustCall((stream) => { + const dest = stream.pipe(fs.createWriteStream(fn)); + + dest.on('finish', () => { + assert.strictEqual(fs.readFileSync(loc).length, + fs.readFileSync(fn).length); + }); + stream.respond(); + stream.end(); +})); + +server.listen(common.PIPE, common.mustCall(() => { + const client = http2.connect('http://localhost', { + createConnection(url) { + return net.connect(server.address()); + } + }); + + const req = client.request({ ':method': 'POST' }); + req.on('response', common.mustCall()); + req.resume(); + + req.on('close', common.mustCall(() => { + server.close(); + client.close(); + })); + + const str = fs.createReadStream(loc); + str.on('end', common.mustCall()); + str.pipe(req); +})); |