-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
HttpHeaders should not remove invalid values during validating access #67199
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsSpinning off the discussion about this specific behavior from #61798.
HttpHeaders headers = new HttpRequestMessage().Headers;
headers.TryAddWithoutValidation("Accept", "invalid");
Assert.Equal(1, headers.NonValidated.Count);
Assert.False(headers.TryGetValues("Accept", out _));
// The entry doesn't exist anymore even for NonValidated accesses
Assert.Equal(0, headers.NonValidated.Count); This means that validated enumeration results in even more side effects to the request/response. The user may expect that only headers visible during enumeration will be present in the request, which is only partially the case today. I recommend we change the behavior here such that invalid values are never implicitly removed. This should result in more consistent behavior and improve the usability of
|
Updated the description to properly note that this only applies to header values that are empty or contain new line characters and were added via |
Triage:
|
This appears to be a quick fix, I hope I can help with this |
Should the "or had a known parser and was just whitespace" work be a separate PR? |
I think it's closely related and can be the same PR - any implicit |
Spinning off the discussion about this specific behavior from #61798.
HttpHeaders
will remove the header entry during a validating read if it contained only values with new lines, or had a known parser and was just whitespace.This means that validated enumeration results in even more side effects to the request/response.
NonValidated
enumeration is not able to report all entries if a validated enumeration occurred before it.I recommend we change the behavior here such that values containing new lines are never implicitly removed. This should result in more consistent behavior and improve the usability of
NonValidated
.This would mean that the user may now observe new-line characters & empty values from
TryGetValues
(given they were added without validation).As a nice bonus, the fact we remove these entries is the biggest complication in reintroducing support for thread-safe concurrent reads (#66989 (comment)).
The text was updated successfully, but these errors were encountered: