|
1 | 1 | package server |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bufio" |
5 | 4 | "bytes" |
6 | 5 | "context" |
7 | 6 | "encoding/json" |
@@ -455,52 +454,6 @@ func TestStreamableHTTP_POST_SendAndReceive_stateless(t *testing.T) { |
455 | 454 | }) |
456 | 455 | } |
457 | 456 |
|
458 | | -func TestStreamableHTTP_GET(t *testing.T) { |
459 | | - mcpServer := NewMCPServer("test-mcp-server", "1.0") |
460 | | - addSSETool(mcpServer) |
461 | | - server := NewTestStreamableHTTPServer(mcpServer) |
462 | | - |
463 | | - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) |
464 | | - defer cancel() |
465 | | - req, err := http.NewRequestWithContext(ctx, "GET", server.URL, nil) |
466 | | - if err != nil { |
467 | | - t.Fatalf("Failed to create request: %v", err) |
468 | | - } |
469 | | - req.Header.Set("Content-Type", "text/event-stream") |
470 | | - |
471 | | - go func() { |
472 | | - time.Sleep(10 * time.Millisecond) |
473 | | - mcpServer.SendNotificationToAllClients("test/notification", map[string]any{ |
474 | | - "value": "all clients", |
475 | | - }) |
476 | | - time.Sleep(10 * time.Millisecond) |
477 | | - }() |
478 | | - |
479 | | - resp, err := server.Client().Do(req) |
480 | | - if err != nil { |
481 | | - t.Fatalf("Failed to send message: %v", err) |
482 | | - } |
483 | | - defer resp.Body.Close() |
484 | | - |
485 | | - if resp.StatusCode != http.StatusAccepted { |
486 | | - t.Errorf("Expected status 202, got %d", resp.StatusCode) |
487 | | - } |
488 | | - |
489 | | - if resp.Header.Get("content-type") != "text/event-stream" { |
490 | | - t.Errorf("Expected content-type text/event-stream, got %s", resp.Header.Get("content-type")) |
491 | | - } |
492 | | - |
493 | | - reader := bufio.NewReader(resp.Body) |
494 | | - _, _ = reader.ReadBytes('\n') // skip first line for event type |
495 | | - bodyBytes, err := reader.ReadBytes('\n') |
496 | | - if err != nil { |
497 | | - t.Fatalf("Failed to read response: %v, bytes: %s", err, string(bodyBytes)) |
498 | | - } |
499 | | - if !strings.Contains(string(bodyBytes), "all clients") { |
500 | | - t.Errorf("Expected all clients, got %s", string(bodyBytes)) |
501 | | - } |
502 | | -} |
503 | | - |
504 | 457 | func TestStreamableHTTP_HttpHandler(t *testing.T) { |
505 | 458 | t.Run("Works with custom mux", func(t *testing.T) { |
506 | 459 | mcpServer := NewMCPServer("test", "1.0.0") |
|
0 commit comments