Draft
Fix multiple bugs: null checks, header case-sensitivity, async patterns, test assertions#18
Conversation
…ion order, HttpHeaders case-sensitivity and bounds check, Task.WaitAll in async context, wrong exception type
Copilot created this pull request from a session on behalf of
daohainam
May 31, 2026 21:53
View session
Copilot stopped work on behalf of
daohainam due to an error
May 31, 2026 21:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR fixes several bugs identified through code review of the codebase.
Changes
1. Fix
ArgumentNullException.ThrowIfNull(nameof(x))— always a no-opFiles: HttpResponseHeaders.cs, Http2FrameWriter.cs, MvcMiddleware.cs, Controller.cs
ThrowIfNull(nameof(value))passes the string literal"value"which is never null — making the check useless. Fixed to pass the actual variable.2. Fix test assertion argument order (expected/actual swapped)
File: ReadRequestTests.cs
Assert.AreEqual(actual, expected)produces misleading failure messages. Fixed toAssert.AreEqual(expected, actual).3. Fix HttpHeaders.Remove crashes when header doesn't exist
File: HttpHeaders.cs
FindIndexreturns -1 when not found, but the code directly indexedheaders[-1], causingIndexOutOfRangeException. Added bounds check.4. Fix case-sensitive header name comparisons
File: HttpHeaders.cs
HTTP headers are case-insensitive per RFC 7230.
AddOrUpdate,AddOrSkip, andRemoveused==for comparison. Fixed to useStringComparison.OrdinalIgnoreCase(consistent with the existingTryGetValuemethod).5. Fix wrong exception type in MultipartFormDataFormReader
File: MultipartFormDataFormReader.cs
Was throwing
NullReferenceException(a runtime-only exception) for invalid state. Changed toInvalidOperationExceptionwhich correctly signals programmer error.6. Fix
Task.WaitAllblocking in async contextFile: MiniWebClientConnection.cs
Replaced synchronous
Task.WaitAll()withawait Task.WhenAll()to prevent thread pool starvation and potential deadlocks in async methods.