forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: add missing stream-like properties to OutgoingMessage
PR-URL: nodejs#29018 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const http = require('http'); | ||
const OutgoingMessage = http.OutgoingMessage; | ||
|
||
{ | ||
const msg = new OutgoingMessage(); | ||
assert.strictEqual(msg.writableObjectMode, false); | ||
} | ||
|
||
{ | ||
const msg = new OutgoingMessage(); | ||
assert(msg.writableHighWaterMark > 0); | ||
} | ||
|
||
{ | ||
const server = http.createServer(common.mustCall(function(req, res) { | ||
const hwm = req.socket.writableHighWaterMark; | ||
assert.strictEqual(res.writableHighWaterMark, hwm); | ||
|
||
assert.strictEqual(res.writableLength, 0); | ||
res.write(''); | ||
const len = res.writableLength; | ||
res.write('asd'); | ||
assert.strictEqual(res.writableLength, len + 8); | ||
res.end(); | ||
res.on('finish', common.mustCall(() => { | ||
assert.strictEqual(res.writableLength, 0); | ||
server.close(); | ||
})); | ||
})); | ||
|
||
server.listen(0); | ||
|
||
server.on('listening', common.mustCall(function() { | ||
const clientRequest = http.request({ | ||
port: server.address().port, | ||
method: 'GET', | ||
path: '/' | ||
}); | ||
clientRequest.end(); | ||
})); | ||
} | ||
|
||
{ | ||
const msg = new OutgoingMessage(); | ||
msg._implicitHeader = function() {}; | ||
assert.strictEqual(msg.writableLength, 0); | ||
msg.write('asd'); | ||
assert.strictEqual(msg.writableLength, 7); | ||
} |