MCPcopy
hub / github.com/axios/axios / request

Function request

tests/smoke/esm/tests/progress.smoke.test.js:12–55  ·  view source on GitHub ↗
(_options, onResponse)

Source from the content-addressed store, hash-verified

10
11 return {
12 request(_options, onResponse) {
13 const req = new Writable({
14 write(_chunk, _encoding, callback) {
15 callback();
16 },
17 });
18
19 req.destroyed = false;
20 req.setTimeout = () => {};
21 req.close = () => {
22 req.destroyed = true;
23 };
24
25 const originalDestroy = req.destroy.bind(req);
26 req.destroy = (...args) => {
27 req.destroyed = true;
28 return originalDestroy(...args);
29 };
30
31 const originalEnd = req.end.bind(req);
32 req.end = (...args) => {
33 originalEnd(...args);
34
35 const res = new PassThrough();
36 res.statusCode = 200;
37 res.statusMessage = 'OK';
38 res.headers = Object.assign(
39 {
40 'content-type': 'text/plain',
41 },
42 responseHeaders
43 );
44 res.req = req;
45
46 onResponse(res);
47
48 responseChunks.forEach((chunk) => {
49 res.write(chunk);
50 });
51 res.end();
52 };
53
54 return req;
55 },
56 };
57};
58

Callers

nothing calls this directly

Calls 3

forEachMethod · 0.80
writeMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected