-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: add writable* properties to compat api
added writableHighWaterMark, writableLength, and writableFinished properties with test. Refs: #29829 PR-URL: #33506 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 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,30 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const server = http2.createServer(common.mustCall((req, res) => { | ||
const hwm = req.socket.writableHighWaterMark; | ||
assert.strictEqual(res.writableHighWaterMark, hwm); | ||
assert.strictEqual(res.writableLength, 0); | ||
res.write(''); | ||
const len = res.writableLength; | ||
res.write('asd'); | ||
assert.strictEqual(res.writableLength, len + 3); | ||
res.end(); | ||
res.on('finish', common.mustCall(() => { | ||
assert.strictEqual(res.writableLength, 0); | ||
assert.ok(res.writableFinished, 'writableFinished is not truthy'); | ||
server.close(); | ||
})); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
const request = client.request(); | ||
request.on('data', common.mustCall()); | ||
request.on('end', common.mustCall(() => { | ||
client.close(); | ||
})); | ||
})); |