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

Function startRequest

test/fixtures/request-and-log.js:43–71  ·  view source on GitHub ↗
(callback)

Source from the content-addressed store, hash-verified

41}
42
43function startRequest(callback) {
44 const req = request(url, {
45 timeout,
46 agent,
47 lookup,
48 }, (res) => {
49 // Log the status code
50 if (!process.env.NO_LOG_REQUEST) {
51 console.log(`Status Code: ${res.statusCode}`);
52 console.log('Headers:', res.headers);
53 }
54 res.pipe(process.stdout);
55
56 if (callback) {
57 res.on('end', callback);
58 }
59 });
60
61 req.on('error', (e) => {
62 console.error('Request Error', e);
63 });
64
65 req.on('timeout', () => {
66 console.error('Request timed out');
67 req.destroy();
68 });
69
70 req.end();
71}
72
73startRequest(() => {
74 if (process.env.CLEAR_GLOBAL_PROXY_AND_RETRY) {

Callers 1

request-and-log.jsFile · 0.70

Calls 6

requestFunction · 0.50
logMethod · 0.45
onMethod · 0.45
errorMethod · 0.45
destroyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…