mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
5c74108891
PR-URL: https://github.com/nodejs/node/pull/46609 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const { fork } = require('child_process');
|
|
const common = require('../common.js');
|
|
const { PIPE } = require('../../test/common');
|
|
const tmpdir = require('../../test/common/tmpdir');
|
|
process.env.PIPE_NAME = PIPE;
|
|
|
|
tmpdir.refresh();
|
|
|
|
// For Node.js versions below v13.3.0 this benchmark will require
|
|
// the flag --max-http-header-size 64000 in order to work properly
|
|
const server = http.createServer({ maxHeaderSize: 64000 }, (req, res) => {
|
|
const headers = {
|
|
'content-type': 'text/plain',
|
|
'content-length': '2',
|
|
};
|
|
res.writeHead(200, headers);
|
|
res.end('ok');
|
|
});
|
|
|
|
server.on('error', (err) => {
|
|
throw new Error(`server error: ${err}`);
|
|
});
|
|
server.listen(PIPE);
|
|
|
|
const child = fork(
|
|
`${__dirname}/_chunky_http_client.js`,
|
|
process.argv.slice(2),
|
|
);
|
|
child.on('message', (data) => {
|
|
if (data.type === 'report') {
|
|
common.sendResult(data);
|
|
}
|
|
});
|
|
child.on('close', (code) => {
|
|
server.close();
|
|
assert.strictEqual(code, 0);
|
|
});
|