-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for Http2ServerResponse#[writableCorked,cork,uncork]
PR-URL: #33956 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
24fd157
commit 998b22c
Showing
1 changed file
with
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (!common.hasCrypto) { common.skip('missing crypto'); } | ||
|
||
// Test for Http2ServerResponse#[writableCorked,cork,uncork] | ||
|
||
const { strictEqual } = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
{ | ||
let corksLeft = 0; | ||
const server = http2.createServer(common.mustCall((req, res) => { | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.write(Buffer.from('1'.repeat(1024))); | ||
res.cork(); | ||
corksLeft++; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.write(Buffer.from('1'.repeat(1024))); | ||
res.cork(); | ||
corksLeft++; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.write(Buffer.from('1'.repeat(1024))); | ||
res.cork(); | ||
corksLeft++; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.write(Buffer.from('1'.repeat(1024))); | ||
res.cork(); | ||
corksLeft++; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.uncork(); | ||
corksLeft--; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.uncork(); | ||
corksLeft--; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.uncork(); | ||
corksLeft--; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.uncork(); | ||
corksLeft--; | ||
strictEqual(res.writableCorked, corksLeft); | ||
res.end(); | ||
})); | ||
server.listen(0, common.mustCall(() => { | ||
const URL = `http://localhost:${server.address().port}`; | ||
const client = http2.connect(URL); | ||
const req = client.request(); | ||
req.on('data', common.mustCall(2)); | ||
req.on('end', common.mustCall(() => { | ||
server.close(); | ||
client.close(); | ||
})); | ||
})); | ||
} |