-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add ResponseHeaderEncodingSelector on HttpSysOptions #66162
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
When migrating from OWIN/Katana + HTTP.sys to ASP.NET Core + HTTP.sys, response headers containing non-ASCII characters are encoded differently.
OWIN/Katana + HTTP.sys: Response header values are encoded as Latin-1 (ISO-8859-1). A character like U+00A0 (non-breaking space) becomes a single byte 0xA0 on the wire.
ASP.NET Core + HTTP.sys: Response header values are encoded as UTF-8. The same U+00A0 becomes two bytes 0xC2 0xA0 on the wire, which clients interpret as two separate characters (Â + NBSP).
Kestrel provides ResponseHeaderEncodingSelector on KestrelServerOptions to control this. HTTP.sys only has UseLatin1RequestHeaders for request headers (added in .NET 5) — there is no equivalent for response headers.
Describe the solution you'd like
Add a UseLatin1ResponseHeaders property (or a more general ResponseHeaderEncoding option) to HttpSysOptions, similar to:
HttpSysOptions.UseLatin1RequestHeaders(existing, request-side only)KestrelServerOptions.ResponseHeaderEncodingSelector(Kestrel equivalent)
This would allow applications migrating from OWIN/Katana to ASP.NET Core HTTP.sys to maintain wire-level compatibility for response headers.
Additional context
Current state in .NET 8/9:
- HttpSysOptions.cs (.NET 8) — only has
UseLatin1RequestHeaders - HttpSysOptions.cs (.NET 9) — same, no response encoding option added
- KestrelServerOptions.ResponseHeaderEncodingSelector — the Kestrel equivalent that already exists