Skip to content

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

@chrisdoopboop

Description

@chrisdoopboop

Describe the bug
In the StreamableHttpHandler, the SDK explicitly sets the Content-Encoding header to "identity" when preparing an SSE (Server-Sent Events) response. This is a violation of RFC 9110 Section 8.4, which governs HTTP Semantics.

To Reproduce
Steps to reproduce the behavior:

  1. Start an MCP server using the AspNetCore SDK.
  2. Initiate a text/event-stream connection using client of choice.
  3. Inspect the response headers.
  4. Observe Content-Encoding: identity in the response.

Expected behavior
Content-Encoding header should be omitted from the response.

Additional context
From RFC 9910

If one or more encodings have been applied to a representation, the sender that applied the encodings MUST generate a Content-Encoding header field that lists the content codings in the order in which they were applied. Note that the coding named "identity" is reserved for its special role in Accept-Encoding and thus SHOULD NOT be included.

Setting this header can cause issues with strict HTTP clients, load balancers, or proxies that validate header compliance. While often used in ASP.NET as a "hack" to bypass compression middleware for streaming responses, it results in a spec-non-compliant response.

Suggestion
Removing the header: Since "identity" is the default when no encoding is present, the header is redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions