Skip to content

Remove explicit SSE content encoding#1598

Open
DragonFSKY wants to merge 1 commit into
modelcontextprotocol:mainfrom
DragonFSKY:fix/1574-sse-content-encoding
Open

Remove explicit SSE content encoding#1598
DragonFSKY wants to merge 1 commit into
modelcontextprotocol:mainfrom
DragonFSKY:fix/1574-sse-content-encoding

Conversation

@DragonFSKY
Copy link
Copy Markdown

@DragonFSKY DragonFSKY commented May 24, 2026

Motivation and Context

Fixes #1574.

SSE responses currently emit Content-Encoding: identity even though no content coding is applied. RFC 9110 section 8.4 defines Content-Encoding as the list of content codings that were applied to the representation and notes that identity is reserved for Accept-Encoding, so it SHOULD NOT be included in Content-Encoding.

Since no SSE content coding is applied here, the response can omit the header while still preserving the existing SSE buffering controls.

Changes

  • Removes the explicit Content-Encoding: identity assignment from SSE response initialization.
  • Updates legacy SSE and Streamable HTTP integration tests to assert that SSE responses do not include a content encoding.
  • Keeps the existing Cache-Control, X-Accel-Buffering, and DisableBuffering() behavior.

How Has This Been Tested?

  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --filter "FullyQualifiedName~EventSourceResponse_Includes_ExpectedHeaders"
    • RED before the production change: 3 failed because the collection contained identity.
    • GREEN after the production change: 3 passed.
  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --no-build --no-restore
    • 377 passed, 18 skipped.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository style guidelines
  • New and existing relevant tests pass locally
  • I have added appropriate regression coverage
  • Documentation updates were not needed for this header-only behavior fix

Signed-off-by: Dongliang Xie <dragonfsky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid Content-Encoding: identity header in SSE responses (RFC 9110 violation)

1 participant