[release/6.0] Fix method HttpHeadersNonValidated uses to get HeaderDescriptor #62194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #62150 to release/6.0
/cc @stephentoub
Fixes #62024
Customer Impact
This API new in 6.0 is not working correctly.
HttpHeaders collections can be associated with a particular kind of header, e.g. HttpRequestMessage.Headers is for request headers. Adding a response header into such a collection should still "work", in that you should still be able to add it and retrieve it, and it should be treated like any arbitrary header. However, the new HttpHeaders.NonValidated property returns a view over the headers that is failing to roundtrip such entries, e.g. if you add a value that would normally be considered a response header into the request headers:
and then try to look it up via NonValidated, it won't find the header:
Testing
Added new unit tests.
Risk
Minimal. There were two subtly different internal APIs for retrieving the descriptor object for a given header name, and we were calling the wrong one in two places.