MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / handleAuthFetch

Function handleAuthFetch

crates/opencode-plugin/host/plugin-host.ts:558–589  ·  view source on GitHub ↗
(
  id: number,
  params: { url: string; method: string; headers: Record<string, string>; body?: string },
)

Source from the content-addressed store, hash-verified

556}
557
558async function handleAuthFetch(
559 id: number,
560 params: { url: string; method: string; headers: Record<string, string>; body?: string },
561): Promise<void> {
562 if (!customFetch) {
563 sendError(id, -32601, "No custom fetch available");
564 return;
565 }
566
567 try {
568 const resp = await customFetch(params.url, {
569 method: params.method,
570 headers: params.headers,
571 body: params.body,
572 });
573
574 const respHeaders: Record<string, string> = {};
575 resp.headers.forEach((v: string, k: string) => {
576 respHeaders[k] = v;
577 });
578
579 const body = await resp.text();
580 sendResult(id, {
581 status: resp.status,
582 headers: respHeaders,
583 body,
584 });
585 } catch (err: unknown) {
586 const msg = err instanceof Error ? err.message : String(err);
587 sendError(id, -32603, `auth.fetch failed: ${msg}`);
588 }
589}
590
591async function handleAuthFetchStream(
592 id: number,

Callers 1

mainFunction · 0.85

Calls 3

sendErrorFunction · 0.85
sendResultFunction · 0.85
textMethod · 0.45

Tested by

no test coverage detected