| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,54 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
| 4 | + | ||
| 5 | + // Test for Http2ServerResponse#[writableCorked,cork,uncork] | ||
| 6 | + | ||
| 7 | + const { strictEqual } = require('assert'); | ||
| 8 | + const http2 = require('http2'); | ||
| 9 | + | ||
| 10 | + { | ||
| 11 | + let corksLeft = 0; | ||
| 12 | + const server = http2.createServer(common.mustCall((req, res) => { | ||
| 13 | + strictEqual(res.writableCorked, corksLeft); | ||
| 14 | + res.write(Buffer.from('1'.repeat(1024))); | ||
| 15 | + res.cork(); | ||
| 16 | + corksLeft++; | ||
| 17 | + strictEqual(res.writableCorked, corksLeft); | ||
| 18 | + res.write(Buffer.from('1'.repeat(1024))); | ||
| 19 | + res.cork(); | ||
| 20 | + corksLeft++; | ||
| 21 | + strictEqual(res.writableCorked, corksLeft); | ||
| 22 | + res.write(Buffer.from('1'.repeat(1024))); | ||
| 23 | + res.cork(); | ||
| 24 | + corksLeft++; | ||
| 25 | + strictEqual(res.writableCorked, corksLeft); | ||
| 26 | + res.write(Buffer.from('1'.repeat(1024))); | ||
| 27 | + res.cork(); | ||
| 28 | + corksLeft++; | ||
| 29 | + strictEqual(res.writableCorked, corksLeft); | ||
| 30 | + res.uncork(); | ||
| 31 | + corksLeft--; | ||
| 32 | + strictEqual(res.writableCorked, corksLeft); | ||
| 33 | + res.uncork(); | ||
| 34 | + corksLeft--; | ||
| 35 | + strictEqual(res.writableCorked, corksLeft); | ||
| 36 | + res.uncork(); | ||
| 37 | + corksLeft--; | ||
| 38 | + strictEqual(res.writableCorked, corksLeft); | ||
| 39 | + res.uncork(); | ||
| 40 | + corksLeft--; | ||
| 41 | + strictEqual(res.writableCorked, corksLeft); | ||
| 42 | + res.end(); | ||
| 43 | + })); | ||
| 44 | + server.listen(0, common.mustCall(() => { | ||
| 45 | + const URL = `http://localhost:${server.address().port}`; | ||
| 46 | + const client = http2.connect(URL); | ||
| 47 | + const req = client.request(); | ||
| 48 | + req.on('data', common.mustCall(2)); | ||
| 49 | + req.on('end', common.mustCall(() => { | ||
| 50 | + server.close(); | ||
| 51 | + client.close(); | ||
| 52 | + })); | ||
| 53 | + })); | ||
| 54 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments