-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: add highWaterMark opt in http.createServer
- Loading branch information
1 parent
af8ed02
commit 244311b
Showing
5 changed files
with
69 additions
and
6 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
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,47 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const { kHighWaterMark } = require('_http_outgoing'); | ||
|
||
const { getDefaultHighWaterMark } = require('internal/streams/state'); | ||
|
||
function listen(server) { | ||
server.listen(0, common.mustCall(() => { | ||
http.get({ | ||
port: server.address().port, | ||
}, (res) => { | ||
assert.strictEqual(res.statusCode, 200); | ||
res.resume().on('end', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
}); | ||
})); | ||
} | ||
|
||
{ | ||
const server = http.createServer({ | ||
highWaterMark: getDefaultHighWaterMark() * 2, | ||
}, common.mustCall((req, res) => { | ||
assert.strictEqual(req._readableState.highWaterMark, getDefaultHighWaterMark() * 2); | ||
assert.strictEqual(res[kHighWaterMark], getDefaultHighWaterMark() * 2); | ||
res.statusCode = 200; | ||
res.end(); | ||
})); | ||
|
||
listen(server); | ||
} | ||
|
||
{ | ||
const server = http.createServer( | ||
common.mustCall((req, res) => { | ||
assert.strictEqual(req._readableState.highWaterMark, getDefaultHighWaterMark()); | ||
assert.strictEqual(res[kHighWaterMark], getDefaultHighWaterMark()); | ||
res.statusCode = 200; | ||
res.end(); | ||
}) | ||
); | ||
|
||
listen(server); | ||
} |
Initially I thought it is better to be safe since it affects performance.
I feel a bit conflicting about this.
Either:
highWaterMark
Inputs are welcomed. 😄