Skip to content

Commit 44c0e73

Browse files
Avoid re-throwing exception in bad request handling path. (#65221)
1 parent 8d90964 commit 44c0e73

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/Http1Connection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,12 @@ protected override bool TryParseRequest(ReadResult result, out bool endConnectio
735735
catch (BadHttpRequestException ex)
736736
{
737737
OnBadRequest(result.Buffer, ex);
738-
throw;
738+
739+
// Avoid re-throwing - handle the bad request state directly here
740+
// to eliminate exception propagation overhead through async state machines
741+
SetBadRequestState(ex);
742+
endConnection = true;
743+
return true;
739744
}
740745
#pragma warning restore CS0618 // Type or member is obsolete
741746
catch (Exception)

0 commit comments

Comments
 (0)