aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

`Content-Encoding: identity` is not a valid value per RFC

Open lvivski opened this issue 2 weeks ago • 4 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

Content-Encoding: identity is not a valid value

RFC references:

RFC 2616, Section 3.5:

identity The default (identity) encoding; the use of no transformation whatsoever. This content-coding is used only in the Accept- Encoding header, and SHOULD NOT be used in the Content-Encoding header.

Newer RFC 7131 mentions it as valid in Accept-Encoding but not in Content-Encoding

RFC 7231 Section 5.3.4:

Accept-Encoding = #( codings [ weight ] ) codings = content-coding / "identity" / "*"

RFC 7231 Section 3.1.2.2:

Content-Encoding = 1#content-coding

Expected Behavior

If no compression is applied, then Content-Encoding header is not necessary

Steps To Reproduce

https://github.com/dotnet/aspnetcore/blob/73ce13e67ec6dbf004b0f85508ae9920e30e0cb6/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsServerTransport.cs#L41

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

lvivski avatar Dec 10 '25 01:12 lvivski

This is done because IIS compresses text/* by default unless a content-encoding header is present. That breaks streaming SSE as it buffers in order to compress the response.

BrennanConroy avatar Dec 10 '25 01:12 BrennanConroy

Is there any other way to bypass compression without manually specifying a content-encoding header?

lvivski avatar Dec 10 '25 01:12 lvivski

Thanks for reaching out, @lvivski. Is there any issue you're observing other than the behavior not being compliant with RFC 7131?

You could always add a callback via HttpResponse.OnStarting() to override the header to something else.

MackinnonBuck avatar Dec 10 '25 18:12 MackinnonBuck

Hi @@lvivski. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.