-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #29053 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
55ca3a8
commit db8144b
Showing
4 changed files
with
101 additions
and
7 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
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
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
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,33 @@ | ||
'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(); | ||
})); | ||
}); | ||
}); |