node/benchmark/http/http_server_for_chunky_client.js
Rich Trott 29e74d4952 benchmark: refactor for consistent style
Code in benchmark directory sometimes uses `function () {}` for
anonymous callbacks and sometimes uses `() => {}`. Multi-line arrays
sometimes have a trailing comma and sometimes do not. Update to always
use arrow functions for anonymous callbacks and trailing commas for
multiline arrays.

PR-URL: https://github.com/nodejs/node/pull/25944
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-06 22:18:31 -08:00

38 lines
815 B
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();
var server;
server = http.createServer((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', common.sendResult);
child.on('close', (code) => {
server.close();
assert.strictEqual(code, 0);
});