11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciif (!common.hasCrypto) { common.skip('missing crypto'); } 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Test for Http2ServerResponse#[writableCorked,cork,uncork] 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert'); 81cb0ef41Sopenharmony_ciconst http2 = require('http2'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci{ 111cb0ef41Sopenharmony_ci let corksLeft = 0; 121cb0ef41Sopenharmony_ci const server = http2.createServer(common.mustCall((req, res) => { 131cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 141cb0ef41Sopenharmony_ci res.write(Buffer.from('1'.repeat(1024))); 151cb0ef41Sopenharmony_ci res.cork(); 161cb0ef41Sopenharmony_ci corksLeft++; 171cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 181cb0ef41Sopenharmony_ci res.write(Buffer.from('1'.repeat(1024))); 191cb0ef41Sopenharmony_ci res.cork(); 201cb0ef41Sopenharmony_ci corksLeft++; 211cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 221cb0ef41Sopenharmony_ci res.write(Buffer.from('1'.repeat(1024))); 231cb0ef41Sopenharmony_ci res.cork(); 241cb0ef41Sopenharmony_ci corksLeft++; 251cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 261cb0ef41Sopenharmony_ci res.write(Buffer.from('1'.repeat(1024))); 271cb0ef41Sopenharmony_ci res.cork(); 281cb0ef41Sopenharmony_ci corksLeft++; 291cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 301cb0ef41Sopenharmony_ci res.uncork(); 311cb0ef41Sopenharmony_ci corksLeft--; 321cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 331cb0ef41Sopenharmony_ci res.uncork(); 341cb0ef41Sopenharmony_ci corksLeft--; 351cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 361cb0ef41Sopenharmony_ci res.uncork(); 371cb0ef41Sopenharmony_ci corksLeft--; 381cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 391cb0ef41Sopenharmony_ci res.uncork(); 401cb0ef41Sopenharmony_ci corksLeft--; 411cb0ef41Sopenharmony_ci strictEqual(res.writableCorked, corksLeft); 421cb0ef41Sopenharmony_ci res.end(); 431cb0ef41Sopenharmony_ci })); 441cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 451cb0ef41Sopenharmony_ci const URL = `http://localhost:${server.address().port}`; 461cb0ef41Sopenharmony_ci const client = http2.connect(URL); 471cb0ef41Sopenharmony_ci const req = client.request(); 481cb0ef41Sopenharmony_ci req.on('data', common.mustCall(2)); 491cb0ef41Sopenharmony_ci req.on('end', common.mustCall(() => { 501cb0ef41Sopenharmony_ci server.close(); 511cb0ef41Sopenharmony_ci client.close(); 521cb0ef41Sopenharmony_ci })); 531cb0ef41Sopenharmony_ci })); 541cb0ef41Sopenharmony_ci} 55