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

Function doReq

test/parallel/test-http2-async-local-storage.js:31–47  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

29 const client = storage.run({ id: 0 }, () => http2.connect(`http://localhost:${server.address().port}`));
30
31 async function doReq(id) {
32 const req = client.request({ [HTTP2_HEADER_PATH]: '/' });
33
34 req.on('response', common.mustCall((headers) => {
35 assert.strictEqual(headers[HTTP2_HEADER_STATUS], 200);
36 assert.strictEqual(id, storage.getStore().id);
37 }));
38 req.on('data', common.mustCall((data) => {
39 assert.strictEqual(data.toString(), 'data');
40 assert.strictEqual(id, storage.getStore().id);
41 }));
42 req.on('end', common.mustCall(() => {
43 assert.strictEqual(id, storage.getStore().id);
44 server.close();
45 client.close();
46 }));
47 }
48
49 function doReqWith(id) {
50 storage.run({ id }, () => doReq(id));

Callers 1

doReqWithFunction · 0.70

Calls 5

requestMethod · 0.65
closeMethod · 0.65
onMethod · 0.45
getStoreMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…