MCPcopy Create free account
hub / github.com/nodejs/node / createServer

Function createServer

test/parallel/test-http-client-leaky-with-double-response.js:8–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const { onGC } = require('../common/gc');
7
8function createServer() {
9 const server = http.createServer(common.mustCall((req, res) => {
10 res.setHeader('Content-Type', 'application/json');
11 res.end(JSON.stringify({ hello: 'world' }));
12 req.socket.write('HTTP/1.1 400 Bad Request\r\n\r\n');
13 }));
14
15 return new Promise((resolve) => {
16 server.listen(0, common.mustCall(() => {
17 resolve(server);
18 }));
19 });
20}
21
22async function main() {
23 const server = await createServer();

Callers 1

mainFunction · 0.70

Calls 5

setHeaderMethod · 0.80
listenMethod · 0.80
resolveFunction · 0.50
endMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected