0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/http/http_server_for_chunky_client.js
Ruben Bridgewater f86f5736da
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679

PR-URL: https://github.com/nodejs/node/pull/26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-30 13:16:39 +01:00

36 lines
808 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();
const 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);
});