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

Function client

test/parallel/test-http-1.0-keep-alive.js:127–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125 }
126
127 function client() {
128 if (current === test.requests.length) return next();
129 const port = server.address().port;
130 const conn = net.createConnection(port, '127.0.0.1', connected);
131
132 function connected() {
133 const ctx = test.requests[current];
134 console.error(' > CLIENT SENDING REQUEST', ctx);
135 conn.setEncoding('utf8');
136 conn.write(ctx.data);
137
138 function onclose() {
139 console.error(' > CLIENT CLOSE');
140 if (!ctx.expectClose) throw new Error('unexpected close');
141 client();
142 }
143 conn.on('close', onclose);
144
145 function ondata(s) {
146 console.error(' > CLIENT ONDATA %j %j', s.length, s.toString());
147 current++;
148 if (ctx.expectClose) return;
149 conn.removeListener('close', onclose);
150 conn.removeListener('data', ondata);
151 connected();
152 }
153 conn.on('data', ondata);
154 }
155 }
156}

Callers 1

oncloseFunction · 0.70

Calls 3

nextFunction · 0.70
addressMethod · 0.65
createConnectionMethod · 0.45

Tested by

no test coverage detected