From f5b364d786a5c337e5d0bc17f7eddb703f9f3f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marie=20P=C3=ADchov=C3=A1?= Date: Fri, 1 Nov 2024 16:51:05 +0100 Subject: [PATCH 1/6] Allow using H/3 with WinHttpHandler --- .../Windows/WinHttp/Interop.winhttp_types.cs | 1 + .../HttpClientHandlerTest.Cancellation.cs | 16 +- .../Net/Http/HttpClientHandlerTest.Proxy.cs | 4 +- ...ttpClientHandlerTest.ServerCertificates.cs | 8 +- .../src/System/Net/Http/WinHttpHandler.cs | 11 +- .../FunctionalTests/PlatformHandlerTest.cs | 180 ++++++++++++++++++ ...ttp.WinHttpHandler.Functional.Tests.csproj | 6 + 7 files changed, 207 insertions(+), 19 deletions(-) diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs index 42b58b7df198d7..689309f196eb25 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs @@ -159,6 +159,7 @@ internal static partial class WinHttp public const uint WINHTTP_OPTION_ENABLE_HTTP_PROTOCOL = 133; public const uint WINHTTP_OPTION_HTTP_PROTOCOL_USED = 134; public const uint WINHTTP_PROTOCOL_FLAG_HTTP2 = 0x1; + public const uint WINHTTP_PROTOCOL_FLAG_HTTP3 = 0x2; public const uint WINHTTP_HTTP2_PLUS_CLIENT_CERT_FLAG = 0x1; public const uint WINHTTP_OPTION_DISABLE_STREAM_QUEUE = 139; diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs index b0a274ad787fcf..13117768c99f99 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs @@ -36,10 +36,10 @@ public async Task PostAsync_CancelDuringRequestContentSend_TaskCanceledQuickly(b return; } - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ if (PlatformDetection.IsBrowser && LoopbackServerFactory.Version < HttpVersion20.Value) { @@ -100,10 +100,10 @@ public async Task GetAsync_CancelDuringResponseHeadersReceived_TaskCanceledQuick return; } - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ using (HttpClient client = CreateHttpClient()) { @@ -208,10 +208,10 @@ public async Task GetAsync_CancelDuringResponseBodyReceived_Unbuffered_TaskCance return; } - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ using (HttpClient client = CreateHttpClient()) { @@ -271,10 +271,10 @@ await ValidateClientCancellationAsync(async () => [SkipOnPlatform(TestPlatforms.Browser, "Browser doesn't have blocking synchronous Stream.ReadByte and so it waits for whole body")] public async Task GetAsync_CancelPendingRequests_DoesntCancelReadAsyncOnResponseStream(CancellationMode mode, bool copyToAsync) { - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ using (HttpClient client = CreateHttpClient()) { diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs index c2031f5aa75ed8..4a3ac150ef431c 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs @@ -29,10 +29,10 @@ public HttpClientHandler_Proxy_Test(ITestOutputHelper output) : base(output) { } [Fact] public async Task Dispose_HandlerWithProxy_ProxyNotDisposed() { - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ var proxy = new TrackDisposalProxy(); diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs index 0ed517ae168426..a3b8d55b956f6f 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs @@ -40,10 +40,10 @@ public HttpClientHandler_ServerCertificates_Test(ITestOutputHelper output) : bas [Fact] public void Ctor_ExpectedDefaultValues() { - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ using (HttpClientHandler handler = CreateHttpClientHandler()) { @@ -55,10 +55,10 @@ public void Ctor_ExpectedDefaultValues() [Fact] public void ServerCertificateCustomValidationCallback_SetGet_Roundtrips() { - if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) + /*if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) { return; - } + }*/ using (HttpClientHandler handler = CreateHttpClientHandler()) { diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs index f73a48f54ecedf..5c9d89077b45ad 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs @@ -1269,7 +1269,7 @@ private void SetRequestHandleOptions(WinHttpRequestState state) SetRequestHandleClientCertificateOptions(state.RequestHandle, state.RequestMessage.RequestUri); SetRequestHandleCredentialsOptions(state); SetRequestHandleBufferingOptions(state.RequestHandle); - SetRequestHandleHttp2Options(state.RequestHandle, state.RequestMessage.Version); + SetRequestHandleHttpProtocolOptions(state.RequestHandle, state.RequestMessage.Version); } private static void SetRequestHandleProxyOptions(WinHttpRequestState state) @@ -1509,20 +1509,21 @@ private void SetRequestHandleBufferingOptions(SafeWinHttpHandle requestHandle) SetWinHttpOption(requestHandle, Interop.WinHttp.WINHTTP_OPTION_MAX_RESPONSE_DRAIN_SIZE, ref optionData); } - private void SetRequestHandleHttp2Options(SafeWinHttpHandle requestHandle, Version requestVersion) + private void SetRequestHandleHttpProtocolOptions(SafeWinHttpHandle requestHandle, Version requestVersion) { Debug.Assert(requestHandle != null); - uint optionData = (requestVersion == HttpVersion20) ? Interop.WinHttp.WINHTTP_PROTOCOL_FLAG_HTTP2 : 0; + uint optionData = (requestVersion == HttpVersion30) ? Interop.WinHttp.WINHTTP_PROTOCOL_FLAG_HTTP3 : + (requestVersion == HttpVersion20) ? Interop.WinHttp.WINHTTP_PROTOCOL_FLAG_HTTP2 : 0; if (Interop.WinHttp.WinHttpSetOption( requestHandle, Interop.WinHttp.WINHTTP_OPTION_ENABLE_HTTP_PROTOCOL, ref optionData)) { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"HTTP/2 option supported, setting to {optionData}"); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"HTTP/{requestVersion.Major} option supported, setting to {optionData}"); } else { - if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "HTTP/2 option not supported"); + if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"HTTP/{requestVersion.Major} option not supported"); } } diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/PlatformHandlerTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/PlatformHandlerTest.cs index 0d2165eda36e91..76d87751948ed5 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/PlatformHandlerTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/PlatformHandlerTest.cs @@ -361,4 +361,184 @@ public sealed class PlatformHandler_ResponseStream_Http2_Test : ResponseStreamTe public PlatformHandler_ResponseStream_Http2_Test(ITestOutputHelper output) : base(output) { } } + +#if NET +#if !WINHTTPHANDLER_TEST // [ActiveIssue("https://github.com/dotnet/runtime/issues/33930")] + [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsWindows10Version1607OrGreater))] + public sealed class PlatformHandlerTest_Cookies_Http3 : HttpClientHandlerTest_Cookies + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandlerTest_Cookies_Http3(ITestOutputHelper output) : base(output) { } + } +#endif + + public sealed class PlatformHandler_HttpClientHandler_Asynchrony_Http3_Test : HttpClientHandler_Asynchrony_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Asynchrony_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpProtocol_Http3_Tests : HttpProtocolTests + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpProtocol_Http3_Tests(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpProtocolTests_Http3_Dribble : HttpProtocolTests_Dribble + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpProtocolTests_Http3_Dribble(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClient_SelectedSites_Http3_Test : HttpClient_SelectedSites_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClient_SelectedSites_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientEKU_Http3_Test : HttpClientEKUTest + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientEKU_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_Decompression_Http3_Tests : HttpClientHandler_Decompression_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Decompression_Http3_Tests(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_DangerousAcceptAllCertificatesValidator_Http3_Test : HttpClientHandler_DangerousAcceptAllCertificatesValidator_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_DangerousAcceptAllCertificatesValidator_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_ClientCertificates_Http3_Test : HttpClientHandler_ClientCertificates_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_ClientCertificates_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_DefaultProxyCredentials_Http3_Test : HttpClientHandler_DefaultProxyCredentials_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_DefaultProxyCredentials_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + [SkipOnPlatform(TestPlatforms.Browser, "MaxConnectionsPerServer not supported on Browser")] + public sealed class PlatformHandler_HttpClientHandler_MaxConnectionsPerServer_Http3_Test : HttpClientHandler_MaxConnectionsPerServer_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_MaxConnectionsPerServer_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_ServerCertificates_Http3_Test : HttpClientHandler_ServerCertificates_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_ServerCertificates_Http3_Test(ITestOutputHelper output) : base(output) + { + AllowAllCertificates = false; + } + } + + public sealed class PlatformHandler_PostScenario_Http3_Test : PostScenarioTest + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_PostScenario_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_SslProtocols_Http3_Test : HttpClientHandler_SslProtocols_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_SslProtocols_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_Proxy_Http3_Test : HttpClientHandler_Proxy_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Proxy_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsWindows10Version1607OrGreater))] + public sealed class PlatformHandler_HttpClientHandler_Http3_Test : HttpClientHandlerTest + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandlerTest_AutoRedirect_Http3 : HttpClientHandlerTest_AutoRedirect + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandlerTest_AutoRedirect_Http3(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_DefaultCredentials_Http3_Test : DefaultCredentialsTest + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_DefaultCredentials_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_IdnaProtocol_Http3_Tests : IdnaProtocolTests + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_IdnaProtocol_Http3_Tests(ITestOutputHelper output) : base(output) { } + // WinHttp on Win7 does not support IDNA + protected override bool SupportsIdna => !PlatformDetection.IsWindows7; + } + + public sealed class PlatformHandlerTest_Cookies_Http11_Http3 : HttpClientHandlerTest_Cookies_Http11 + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandlerTest_Cookies_Http11_Http3(ITestOutputHelper output) : base(output) { } + } + + [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsWindows10Version1607OrGreater))] + public sealed class PlatformHandler_HttpClientHandler_MaxResponseHeadersLength_Http3_Test : HttpClientHandler_MaxResponseHeadersLength_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_MaxResponseHeadersLength_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_Cancellation_Http3_Test : HttpClientHandler_Cancellation_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Cancellation_Http3_Test(ITestOutputHelper output) : base(output) { } + } + + public sealed class PlatformHandler_HttpClientHandler_Authentication_Http3_Test : HttpClientHandler_Authentication_Test + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_HttpClientHandler_Authentication_Http3_Test(ITestOutputHelper output) : base(output) { } + } + public sealed class PlatformHandler_ResponseStream_Http3_Test : ResponseStreamTest + { + protected override Version UseVersion => HttpVersion.Version30; + + public PlatformHandler_ResponseStream_Http3_Test(ITestOutputHelper output) : base(output) { } + } +#endif } diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj index c5c7099713aa5f..4a90073d5e8b0e 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/System.Net.Http.WinHttpHandler.Functional.Tests.csproj @@ -149,6 +149,12 @@ + + + From 4ed5450956b8acfe5ac1c740d881ccee3c98a190 Mon Sep 17 00:00:00 2001 From: Ahmet Ibrahim Aksoy Date: Thu, 23 Jan 2025 16:04:21 +0300 Subject: [PATCH 2/6] Add Protocol Required Option --- .../Windows/WinHttp/Interop.winhttp_types.cs | 1 + .../src/System/Net/Http/WinHttpHandler.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs index 689309f196eb25..9dcdcc8428d00b 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.cs @@ -162,6 +162,7 @@ internal static partial class WinHttp public const uint WINHTTP_PROTOCOL_FLAG_HTTP3 = 0x2; public const uint WINHTTP_HTTP2_PLUS_CLIENT_CERT_FLAG = 0x1; public const uint WINHTTP_OPTION_DISABLE_STREAM_QUEUE = 139; + public const uint WINHTTP_OPTION_HTTP_PROTOCOL_REQUIRED = 145; public const uint WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET = 114; public const uint WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT = 115; diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs index 5c9d89077b45ad..11a43225ff316b 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs @@ -904,6 +904,14 @@ private async Task StartRequestAsync(WinHttpRequestState state) { httpVersion = "HTTP/1.1"; } + else if (state.RequestMessage.Version == HttpVersion20) + { + httpVersion = "HTTP/2.0"; + } + else if (state.RequestMessage.Version == HttpVersion30) + { + httpVersion = "HTTP/3.0"; + } OpenRequestHandle(state, connectHandle, httpVersion, out WinHttpChunkMode chunkedModeForSend, out SafeWinHttpHandle requestHandle); state.RequestHandle = requestHandle; @@ -1524,6 +1532,19 @@ private void SetRequestHandleHttpProtocolOptions(SafeWinHttpHandle requestHandle else { if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, $"HTTP/{requestVersion.Major} option not supported"); + return; + } + + if (optionData != 0) + { + uint protocolRequired = 1; + if (!Interop.WinHttp.WinHttpSetOption( + requestHandle, + Interop.WinHttp.WINHTTP_OPTION_HTTP_PROTOCOL_REQUIRED, + ref protocolRequired)) + { + if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "HTTP protocol required option not supported"); + } } } From efc553b5d6ccf7da587d0acb880b5f19c7cb9687 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Fri, 24 Oct 2025 16:31:07 +0200 Subject: [PATCH 3/6] Do not require the protocol, allow fallback --- .../src/System/Net/Http/WinHttpHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs index 11a43225ff316b..1c2d8f68db79df 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs @@ -1535,7 +1535,7 @@ private void SetRequestHandleHttpProtocolOptions(SafeWinHttpHandle requestHandle return; } - if (optionData != 0) + /*if (optionData != 0) { uint protocolRequired = 1; if (!Interop.WinHttp.WinHttpSetOption( @@ -1545,7 +1545,7 @@ private void SetRequestHandleHttpProtocolOptions(SafeWinHttpHandle requestHandle { if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(this, "HTTP protocol required option not supported"); } - } + }*/ } private void SetWinHttpOption(SafeWinHttpHandle handle, uint option, ref uint optionData) From f2f6aef34f3484970978c158ddb257f971900cd4 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Wed, 29 Oct 2025 12:46:46 +0100 Subject: [PATCH 4/6] logging --- .../System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs index b449f5025276dc..03c13ac32cba86 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs @@ -6,6 +6,7 @@ using System.Security.Authentication; using System.Threading.Tasks; using Microsoft.DotNet.XUnitExtensions; +using TestUtilities; using Xunit; using Xunit.Abstractions; @@ -48,6 +49,7 @@ public void SingletonReturnsTrue() [InlineData(SslProtocols.None, true)] public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol, bool requestOnlyThisProtocol) { + var _ = new TestEventListener(_output, TestEventListener.NetworkingEvents); #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete // Overriding flag for the same reason we skip tests on Catalina // On OSX 10.13-10.14 we can override this flag to enable the scenario From 992039fa9d5c1498e40fe15df7bffcae80983ee6 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Thu, 30 Oct 2025 13:51:21 +0100 Subject: [PATCH 5/6] Fix loopback server for H/3 --- .../HttpClientHandlerTestBase.WinHttpHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs index 81773638085d93..131dd22ced76ec 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs @@ -41,8 +41,10 @@ protected static LoopbackServerFactory GetFactoryForVersion(Version useVersion) { return useVersion.Major switch { + 1 => Http11LoopbackServerFactory.Singleton, 2 => Http2LoopbackServerFactory.Singleton, - _ => Http11LoopbackServerFactory.Singleton + 3 => Http3LoopbackServerFactory.Singleton, + _ => throw new InvalidOperationException($"Unexpected HTTP version: {useVersion}") }; } From 620c4983a2f5ccc42573396317450e67246ce9f3 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Thu, 30 Oct 2025 14:45:29 +0100 Subject: [PATCH 6/6] Only on core --- .../FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs index 131dd22ced76ec..b54ca6a85b729d 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs @@ -43,7 +43,9 @@ protected static LoopbackServerFactory GetFactoryForVersion(Version useVersion) { 1 => Http11LoopbackServerFactory.Singleton, 2 => Http2LoopbackServerFactory.Singleton, +#if NET 3 => Http3LoopbackServerFactory.Singleton, +#endif _ => throw new InvalidOperationException($"Unexpected HTTP version: {useVersion}") }; }