From 49973f01ea0075142667783c099d96d3c0611e00 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 12 Jul 2022 18:57:26 +0200 Subject: [PATCH 1/2] utilize ProtocolException for HTTP/2 in HttpStress --- .../StressTests/HttpStress/ClientOperations.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs index 0f8a249a7665d7..6e8d2168e8fb90 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs @@ -303,21 +303,16 @@ public static (string name, Func operation)[] Operations = return; } - string? name = e.InnerException?.GetType().Name; - switch (name) + if (ctx.HttpVersion == HttpVersion.Version20 && + e is HttpProtocolException protocolException && + (protocolException.ErrorCode == 0x2 || // INTERNAL_ERROR, UseKestrel (https://github.com/dotnet/aspnetcore/issues/12256) + protocolException.ErrorCode == 0x8)) // CANCEL, UseHttpSys { - case "Http2ProtocolException": - case "Http2ConnectionException": - case "Http2StreamException": - if ((e.InnerException?.Message?.Contains("INTERNAL_ERROR") ?? false) || // UseKestrel (https://github.com/dotnet/aspnetcore/issues/12256) - (e.InnerException?.Message?.Contains("CANCEL") ?? false)) // UseHttpSys - { - return; - } - break; + return; } } + // TODO: change when HttpProtocolException gets implemented for HTTP/3 if (ctx.HttpVersion == HttpVersion.Version30) { // HTTP/3 exception nesting: From 5ecd9eab9671a4cc74b436cf539be10b64f4b0e9 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 15 Jul 2022 22:17:37 +0200 Subject: [PATCH 2/2] fix build error --- .../HttpStress/ClientOperations.cs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs index 244aafeec7d12c..e557ea40ffb7ec 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs @@ -298,27 +298,16 @@ public static (string name, Func operation)[] Operations = if (e is IOException ioe) { - if (ctx.HttpVersion < HttpVersion.Version20) - { - return; - } - - if (ctx.HttpVersion == HttpVersion.Version20 && + if (ctx.HttpVersion < HttpVersion.Version20 || e is HttpProtocolException protocolException && - (protocolException.ErrorCode == 0x2 || // INTERNAL_ERROR, UseKestrel (https://github.com/dotnet/aspnetcore/issues/12256) - protocolException.ErrorCode == 0x8)) // CANCEL, UseHttpSys + (protocolException.ErrorCode == 0x2 || // INTERNAL_ERROR, UseKestrel (https://github.com/dotnet/aspnetcore/issues/12256) + protocolException.ErrorCode == 0x8 || // CANCEL, UseHttpSys + protocolException.ErrorCode == 0x102)) // H3_INTERNAL_ERROR (258) { return; } } - if (ctx.HttpVersion == HttpVersion.Version30 && - e is HttpProtocolException protocolException && - protocolException.ErrorCode == 258) // 258 = H3_INTERNAL_ERROR (0x102) - { - return; - } - throw; } }),