1'use strict'; 2const common = require('../common'); 3const http = require('http'); 4const assert = require('assert'); 5 6const server = http.createServer((req, res) => { 7 let corked = false; 8 const originalWrite = res.socket.write; 9 res.socket.write = common.mustCall((...args) => { 10 assert.strictEqual(corked, false); 11 return originalWrite.call(res.socket, ...args); 12 }, 5); 13 corked = true; 14 res.cork(); 15 assert.strictEqual(res.writableCorked, res.socket.writableCorked); 16 res.cork(); 17 assert.strictEqual(res.writableCorked, res.socket.writableCorked); 18 res.writeHead(200, { 'a-header': 'a-header-value' }); 19 res.uncork(); 20 assert.strictEqual(res.writableCorked, res.socket.writableCorked); 21 corked = false; 22 res.end('asd'); 23 assert.strictEqual(res.writableCorked, res.socket.writableCorked); 24}); 25 26server.listen(0, () => { 27 http.get({ port: server.address().port }, (res) => { 28 res.on('data', common.mustCall()); 29 res.on('end', common.mustCall(() => { 30 server.close(); 31 })); 32 }); 33}); 34