mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
2fbe124e68
Add highWaterMark option when creating a new HTTP server. This option will override the default (readable|writable) highWaterMark values on sockets created. Fixes: https://github.com/nodejs/node/issues/46606 PR-URL: https://github.com/nodejs/node/pull/47405 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
// 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);
|
|
}
|