From 93409686a1a7c1b81bd2bb0ca1f818ca11ebd577 Mon Sep 17 00:00:00 2001 From: Dongliang Xie Date: Sun, 24 May 2026 10:28:25 +0800 Subject: [PATCH] Remove explicit SSE content encoding Signed-off-by: Dongliang Xie --- src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs | 1 - .../SseServerIntegrationTests.cs | 2 +- .../StreamableHttpServerIntegrationTests.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs b/src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs index 49922b8d9..31f666943 100644 --- a/src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs +++ b/src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs @@ -478,7 +478,6 @@ internal static void InitializeSseResponse(HttpContext context) context.Response.Headers.CacheControl = "no-cache,no-store"; // Make sure we disable all response buffering for SSE. - context.Response.Headers.ContentEncoding = "identity"; context.Response.Headers["X-Accel-Buffering"] = "no"; context.Features.GetRequiredFeature().DisableBuffering(); } diff --git a/tests/ModelContextProtocol.AspNetCore.Tests/SseServerIntegrationTests.cs b/tests/ModelContextProtocol.AspNetCore.Tests/SseServerIntegrationTests.cs index 0bf4aff19..3d9997fb0 100644 --- a/tests/ModelContextProtocol.AspNetCore.Tests/SseServerIntegrationTests.cs +++ b/tests/ModelContextProtocol.AspNetCore.Tests/SseServerIntegrationTests.cs @@ -22,7 +22,7 @@ public async Task EventSourceResponse_Includes_ExpectedHeaders() sseResponse.EnsureSuccessStatusCode(); Assert.Equal("text/event-stream", sseResponse.Content.Headers.ContentType?.MediaType); - Assert.Equal("identity", sseResponse.Content.Headers.ContentEncoding.ToString()); + Assert.Empty(sseResponse.Content.Headers.ContentEncoding); Assert.NotNull(sseResponse.Headers.CacheControl); Assert.True(sseResponse.Headers.CacheControl.NoStore); Assert.True(sseResponse.Headers.CacheControl.NoCache); diff --git a/tests/ModelContextProtocol.AspNetCore.Tests/StreamableHttpServerIntegrationTests.cs b/tests/ModelContextProtocol.AspNetCore.Tests/StreamableHttpServerIntegrationTests.cs index b2b0b5499..64397169e 100644 --- a/tests/ModelContextProtocol.AspNetCore.Tests/StreamableHttpServerIntegrationTests.cs +++ b/tests/ModelContextProtocol.AspNetCore.Tests/StreamableHttpServerIntegrationTests.cs @@ -35,7 +35,7 @@ public async Task EventSourceResponse_Includes_ExpectedHeaders() sseResponse.EnsureSuccessStatusCode(); Assert.Equal("text/event-stream", sseResponse.Content.Headers.ContentType?.MediaType); - Assert.Equal("identity", sseResponse.Content.Headers.ContentEncoding.ToString()); + Assert.Empty(sseResponse.Content.Headers.ContentEncoding); Assert.NotNull(sseResponse.Headers.CacheControl); Assert.True(sseResponse.Headers.CacheControl.NoStore); Assert.True(sseResponse.Headers.CacheControl.NoCache);