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

Function sendRequest

test/parallel/test-http-expect-continue-reuse-race.js:77–117  ·  view source on GitHub ↗
(port)

Source from the content-addressed store, hash-verified

75}));
76
77function sendRequest(port) {
78 let timeout;
79 const promise = new Promise((resolve, reject) => {
80 function done(err) {
81 clearTimeout(timeout);
82 if (err)
83 reject(err);
84 else
85 resolve();
86 }
87
88 const req = http.request({
89 port,
90 host: '127.0.0.1',
91 method: 'POST',
92 agent,
93 headers: {
94 'Content-Length': '0',
95 'Expect': '100-continue',
96 },
97 }, common.mustCall((res) => {
98 assert.strictEqual(res.statusCode, 200);
99 res.resume();
100 res.once('end', done);
101 res.once('error', done);
102 }));
103
104 req.on('socket', patchSocket);
105
106 timeout = setTimeout(() => {
107 const err = new Error('request timed out');
108 req.destroy(err);
109 done(err);
110 }, common.platformTimeout(5000));
111
112 req.once('error', done);
113
114 setTimeout(() => req.end(Buffer.alloc(0)), 0);
115 });
116 return promise.finally(() => clearTimeout(timeout));
117}

Callers 2

runFunction · 0.70

Calls 10

allocMethod · 0.80
doneFunction · 0.70
requestMethod · 0.65
resumeMethod · 0.65
setTimeoutFunction · 0.50
clearTimeoutFunction · 0.50
onceMethod · 0.45
onMethod · 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…