MCPcopy
hub / github.com/continuedev/continue / logRequest

Function logRequest

packages/fetch/src/fetch.ts:12–54  ·  view source on GitHub ↗
(
  method: string,
  url: URL,
  headers: { [key: string]: string },
  body: BodyInit | null | undefined,
  proxy?: string,
  shouldBypass?: boolean,
)

Source from the content-addressed store, hash-verified

10const { http, https } = (followRedirects as any).default;
11
12function logRequest(
13 method: string,
14 url: URL,
15 headers: { [key: string]: string },
16 body: BodyInit | null | undefined,
17 proxy?: string,
18 shouldBypass?: boolean,
19) {
20 console.log("=== FETCH REQUEST ===");
21 console.log(`Method: ${method}`);
22 console.log(`URL: ${url.toString()}`);
23
24 // Log headers in curl format
25 console.log("Headers:");
26 for (const [key, value] of Object.entries(headers)) {
27 console.log(` -H '${key}: ${value}'`);
28 }
29
30 // Log proxy information
31 if (proxy && !shouldBypass) {
32 console.log(`Proxy: ${proxy}`);
33 }
34
35 // Log body
36 if (body) {
37 console.log(`Body: ${body}`);
38 }
39
40 // Generate equivalent curl command
41 let curlCommand = `curl -X ${method}`;
42 for (const [key, value] of Object.entries(headers)) {
43 curlCommand += ` -H '${key}: ${value}'`;
44 }
45 if (body) {
46 curlCommand += ` -d '${body}'`;
47 }
48 if (proxy && !shouldBypass) {
49 curlCommand += ` --proxy '${proxy}'`;
50 }
51 curlCommand += ` '${url.toString()}'`;
52 console.log(`Equivalent curl: ${curlCommand}`);
53 console.log("=====================");
54}
55
56async function logResponse(resp: Response) {
57 console.log("=== FETCH RESPONSE ===");

Callers 1

fetchwithRequestOptionsFunction · 0.85

Calls 1

logMethod · 0.65

Tested by

no test coverage detected