MCPcopy Index your code
hub / github.com/github/copilot-sdk / buildFetchRequest

Function buildFetchRequest

nodejs/src/copilotRequestHandler.ts:646–674  ·  view source on GitHub ↗
(exchange: CopilotRequestExchange)

Source from the content-addressed store, hash-verified

644]);
645
646async function buildFetchRequest(exchange: CopilotRequestExchange): Promise<Request> {
647 const headers = new Headers();
648 for (const [name, values] of Object.entries(exchange.headers)) {
649 if (!values) {
650 continue;
651 }
652 if (FORBIDDEN_REQUEST_HEADERS.has(name.toLowerCase())) {
653 continue;
654 }
655 for (const value of values) {
656 headers.append(name, value);
657 }
658 }
659
660 const method = exchange.method.toUpperCase();
661 const hasBody = method !== "GET" && method !== "HEAD";
662
663 let body: Uint8Array | undefined;
664 if (hasBody) {
665 const buffered = await drainAsync(exchange.requestBody);
666 if (buffered.length > 0) {
667 body = buffered;
668 }
669 } else {
670 await drainAsync(exchange.requestBody);
671 }
672
673 return new Request(exchange.url, { method, headers, body });
674}
675
676async function drainAsync(stream: AsyncIterable<Uint8Array>): Promise<Uint8Array> {
677 const parts: Uint8Array[] = [];

Callers 1

#handleHttpMethod · 0.85

Calls 2

drainAsyncFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…