-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP header encoding #37024
Comments
Tagging subscribers to this area: @dotnet/ncl |
This used to work on .NET Framework -- from compat perspective we will have to enable that - maybe as an opt-in config, or API, maybe as default. |
@MihaZupan can you please look at a repro? I think we need to investigate these things on .NET Framework 4.8 and .NET Core 3.1/5.0, how they behave today to make decision how we want them to behave in 5.0:
(I might have missed some interesting cases) We will need repro for test case in .NET 5. All this info will help us decide how sane the .NET Framework behavior is and how to expose it in .NET Core -- as default behavior, as context-switch opt-in behavior, or as new API. |
I setup a repro to answer @karelz's questions above. Test setup:
On the client side, I'm showing header values as strings in the tables below, since that's the representation exposed by HttpClient apis. On the server side, I'm showing the raw header bytes. Request header tests:
Response header tests:
For request headers, WebRequestHandler is just sending the low byte of each character code in the string. If the high byte is set, it gets truncated. For response headers, the behavior is similar. Each byte on the wire is mapped to a char with the same character code. The only exceptions are CTL chars (byte values 0-31 and 127), which don't seem to be permitted in the response. The test project is attached: |
Closing as the APIs to control header value encoding have been merged. |
The HTTP spec is weak on what encoding is used for headers. Some treat it as UTF-8 others as ASCII/Latin1. There should be a way to control what encoding is used when converting headers to/from string.
The text was updated successfully, but these errors were encountered: