MCPcopy Index your code
hub / github.com/nodejs/node / serverTest

Function serverTest

test/parallel/test-http-server-keep-alive-timeout.js:26–56  ·  view source on GitHub ↗
(withPipeline, cb)

Source from the content-addressed store, hash-verified

24}
25
26function serverTest(withPipeline, cb) {
27 let gotAll = false;
28 let timedout = false;
29 const server = http.createServer(common.mustCall((req, res) => {
30 if (withPipeline)
31 res.end();
32 if (req.url === '/3') {
33 gotAll = true;
34 if (timedout)
35 done(server, req.socket, cb);
36 }
37 }, 3));
38 server.setTimeout(500, common.mustCallAtLeast((socket) => {
39 // End this test and call `run()` for the next test (if any).
40 timedout = true;
41 if (gotAll)
42 done(server, socket, cb);
43 }));
44 server.keepAliveTimeout = 50;
45 server.listen(0, common.mustCall(() => {
46 const options = {
47 port: server.address().port,
48 allowHalfOpen: true
49 };
50 const c = net.connect(options, () => {
51 c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n');
52 c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n');
53 c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n');
54 });
55 }));
56}
57
58test(function serverEndKeepAliveTimeoutWithPipeline(cb) {
59 serverTest(true, cb);

Calls 7

listenMethod · 0.80
doneFunction · 0.70
addressMethod · 0.65
connectMethod · 0.65
endMethod · 0.45
setTimeoutMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…