mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 06:19:07 +00:00

PR-URL: https://github.com/nodejs/node/pull/29053 Reviewed-By: Anna Henningsen <anna@addaleax.net>
34 lines
1017 B
JavaScript
34 lines
1017 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
const assert = require('assert');
|
|
|
|
const server = http.createServer((req, res) => {
|
|
let corked = false;
|
|
const originalWrite = res.socket.write;
|
|
res.socket.write = common.mustCall((...args) => {
|
|
assert.strictEqual(corked, false);
|
|
return originalWrite.call(res.socket, ...args);
|
|
}, 5);
|
|
corked = true;
|
|
res.cork();
|
|
assert.strictEqual(res.writableCorked, res.socket.writableCorked);
|
|
res.cork();
|
|
assert.strictEqual(res.writableCorked, res.socket.writableCorked);
|
|
res.writeHead(200, { 'a-header': 'a-header-value' });
|
|
res.uncork();
|
|
assert.strictEqual(res.writableCorked, res.socket.writableCorked);
|
|
corked = false;
|
|
res.end('asd');
|
|
assert.strictEqual(res.writableCorked, res.socket.writableCorked);
|
|
});
|
|
|
|
server.listen(0, () => {
|
|
http.get({ port: server.address().port }, (res) => {
|
|
res.on('data', common.mustCall());
|
|
res.on('end', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
});
|
|
});
|