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

Function makeReq

test/parallel/test-http2-session-timeout.js:32–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 makeReq();
31
32 function makeReq() {
33 const request = client.request({
34 ':path': '/foobar',
35 ':method': 'GET',
36 ':scheme': 'http',
37 ':authority': `localhost:${port}`,
38 });
39 request.resume();
40 request.end();
41
42 requests += 1;
43
44 request.on('end', () => {
45 const diff = hrtime() - startTime;
46 const milliseconds = diff / NS_PER_MS;
47 if (server.timeout === 0n) {
48 // Set the timeout now. First connection will take significantly longer
49 // than subsequent connections, so using the duration of the first
50 // connection as the timeout should be robust. Double it anyway for good
51 // measure.
52 server.timeout = milliseconds * 2n;
53 startTime = hrtime();
54 makeReq();
55 } else if (milliseconds < server.timeout * 2n) {
56 makeReq();
57 } else {
58 server.removeListener('timeout', mustNotCall);
59 server.close();
60 client.close();
61 }
62 });
63 }
64}));

Callers 1

Calls 7

hrtimeFunction · 0.85
requestMethod · 0.65
resumeMethod · 0.65
closeMethod · 0.65
endMethod · 0.45
onMethod · 0.45
removeListenerMethod · 0.45

Tested by

no test coverage detected