• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const assert = require('assert');
4const http = require('http');
5const { fork } = require('child_process');
6const common = require('../common.js');
7const { PIPE } = require('../../test/common');
8const tmpdir = require('../../test/common/tmpdir');
9process.env.PIPE_NAME = PIPE;
10
11tmpdir.refresh();
12
13// For Node.js versions below v13.3.0 this benchmark will require
14// the flag --max-http-header-size 64000 in order to work properly
15const server = http.createServer({ maxHeaderSize: 64000 }, (req, res) => {
16  const headers = {
17    'content-type': 'text/plain',
18    'content-length': '2',
19  };
20  res.writeHead(200, headers);
21  res.end('ok');
22});
23
24server.on('error', (err) => {
25  throw new Error(`server error: ${err}`);
26});
27server.listen(PIPE);
28
29const child = fork(
30  `${__dirname}/_chunky_http_client.js`,
31  process.argv.slice(2),
32);
33child.on('message', (data) => {
34  if (data.type === 'report') {
35    common.sendResult(data);
36  }
37});
38child.on('close', (code) => {
39  server.close();
40  assert.strictEqual(code, 0);
41});
42