]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ui: fake 200 for proxy DELETE req (#25298)
authorXuan-Son Nguyen <redacted>
Mon, 6 Jul 2026 06:41:39 +0000 (08:41 +0200)
committerGitHub <redacted>
Mon, 6 Jul 2026 06:41:39 +0000 (08:41 +0200)
tools/ui/src/lib/services/mcp.service.ts
tools/ui/tests/unit/mcp-service.test.ts

index 4432989171d1898d26b9eff09af54d5d18c8d29e..ae98632a6fe638831fa52228d72874a6dae3a953 100644 (file)
@@ -314,6 +314,30 @@ export class MCPService {
                                        )
                                );
 
+                               if (method === 'DELETE' && url.includes(CORS_PROXY_ENDPOINT)) {
+                                       const response = new Response(null, { status: 200, statusText: 'OK' });
+
+                                       logIfEnabled(
+                                               this.createLog(
+                                                       MCPConnectionPhase.INITIALIZING,
+                                                       `HTTP 200 ${method} ${url} (fake response)`,
+                                                       MCPLogLevel.INFO,
+                                                       {
+                                                               response: {
+                                                                       url,
+                                                                       status: response.status,
+                                                                       statusText: response.statusText,
+                                                                       durationMs: 0,
+                                                                       isFake: true
+                                                               }
+                                                       }
+                                               )
+                                       );
+
+                                       // fake response, bypass real fetch()
+                                       return response;
+                               }
+
                                try {
                                        const response = await fetch(input, {
                                                ...baseInit,
index 1f6fdda377d0b428c99d23529b05197a323656b3..d3af906813aaed68e38785223c39968331dcb333 100644 (file)
@@ -154,6 +154,32 @@ describe('MCPService', () => {
                });
        });
 
+       it('DELETE request with CORS proxy should return a fake 200 response', async () => {
+               const logs: MCPConnectionLog[] = [];
+               const fetchMock = vi.fn();
+
+               vi.stubGlobal('fetch', fetchMock);
+
+               const config: MCPServerConfig = {
+                       url: 'https://example.com/mcp',
+                       transport: MCPTransportType.STREAMABLE_HTTP,
+                       useProxy: true
+               };
+
+               const controller = createDiagnosticFetch(config, (log) => logs.push(log), {}, true);
+
+               const response = await controller.fetch(
+                       'http://localhost:8080/cors-proxy?url=https%3A%2F%2Fexample.com%2Fmcp',
+                       { method: 'DELETE' }
+               );
+
+               expect(fetchMock).not.toHaveBeenCalled();
+               expect(response.status).toBe(200);
+               expect(logs.at(-1)?.details).toMatchObject({
+                       response: { status: 200, isFake: true }
+               });
+       });
+
        it('partially redacts mcp-session-id in diagnostic request and response logs', async () => {
                const logs: MCPConnectionLog[] = [];
                const response = new Response('{}', {