MCPcopy Create free account
hub / github.com/cloudflare/computer / request

Function request

packages/computerd/src/cli/computerd.test.ts:450–468  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

448}
449
450function request(url) {
451 return new Promise((resolve, reject) => {
452 const request = http.get(url, (response) => {
453 response.setEncoding("utf8");
454 let body = "";
455 response.on("data", (chunk) => {
456 body += chunk;
457 });
458 response.on("end", () => {
459 resolve({ body, headers: response.headers, statusCode: response.statusCode });
460 });
461 });
462
463 request.once("error", reject);
464 request.setTimeout(1_000, () => {
465 request.destroy(new Error(`request timed out: ${url}`));
466 });
467 });
468}
469
470function isConnectionError(error) {
471 return error && ["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT"].includes(error.code);

Callers 3

computerd.test.tsFile · 0.85
waitForHTTPOKFunction · 0.85
httpGetFunction · 0.85

Calls 3

getMethod · 0.65
setTimeoutMethod · 0.65
destroyMethod · 0.65

Tested by

no test coverage detected