MCPcopy Create free account
hub / github.com/X-Profiler/xprofiler / onHttpServerRequestStart

Function onHttpServerRequestStart

patch/http.js:21–49  ·  view source on GitHub ↗
({ request, response })

Source from the content-addressed store, hash-verified

19 setHttpConfig(httpConfig);
20
21 function onHttpServerRequestStart({ request, response }) {
22 addLiveRequest();
23
24 const start = Date.now();
25
26 const timer = setTimeout(() => {
27 addRequestTimeout();
28 if (httpConfig.http_detail_profiling) {
29 const detail = getRequestDetail(request, response, start, 0);
30 addHttpProfilingDetail(detail);
31 }
32 }, patch_http_timeout * 1000);
33 timer.unref();
34
35 response.on('finish', () => {
36 addHttpStatusCode(response.statusCode);
37 addSentRequest(Date.now() - start);
38 clearTimeout(timer);
39 if (httpConfig.http_detail_profiling) {
40 const detail = getRequestDetail(request, response, start, 1);
41 addHttpProfilingDetail(detail);
42 }
43 });
44
45 response.on('close', () => {
46 addCloseRequest();
47 clearTimeout(timer);
48 });
49 }
50
51 // https://nodejs.org/docs/latest/api/diagnostics_channel.html#http
52 // use diagnostics_channel

Callers

nothing calls this directly

Calls 5

addLiveRequestFunction · 0.85
getRequestDetailFunction · 0.85
addHttpStatusCodeFunction · 0.85
addSentRequestFunction · 0.85
addCloseRequestFunction · 0.85

Tested by

no test coverage detected