Stop using InvalidOperationExceptions to signal invalid ASCII during parsing
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
GetAsciiStringNonNullCharacters() currently throws an InvalidOperationException fo invalid or chacters, and the parsing logic catches these InvalidOperationExceptions at [various](https://github.com/aspnet/KestrelHttpServer/blob/6551eae321cd6306b485906ea47e8d41e932d65b/src/Kestrel.Core/Internal/Http/Http1Connection.cs#L469) [layers](https://github.com/aspnet/KestrelHttpServer/blob/6551eae321cd6306b485906ea47e8d41e932d65b/src/Kestrel.Core/Internal/Http/Http1Connection.cs#L261) to handle the bad request appropriately.
Ideally we could switch to calling a TryGetAsciiStringNonNullCharacters method, but if propagating failure down the stack proves too difficult, we should at least move to a custom exception type so we don't end up obscuring real product bugs by inadvertently swallowing InvalidOperationExceptions thrown by other methods.
Contributor guide
Assessment
This issue has not been assessed yet.