From 50a60e7c52f4833e5014b5f8c2e7fc2609297197 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marie=20P=C3=ADchov=C3=A1?= <11718369+ManickaP@users.noreply.github.com> Date: Fri, 6 Aug 2021 09:30:52 +0200 Subject: [PATCH] HTTP/3 Reenabled cookie tests (#56831) * Reenabled cookie tests * Disabled mock cookie tests * Handle H_REQUEST_REJECTED with retry * Reenable mock * Disabled only tests which use more than 1 server connection --- .../Net/Http/HttpClientHandlerTest.Cookies.cs | 24 ++++++++++++++++++++++ .../Http/SocketsHttpHandler/Http3RequestStream.cs | 10 ++++++--- .../FunctionalTests/SocketsHttpHandlerTest.cs | 2 -- .../tests/FunctionalTests/QuicStreamTests.cs | 4 ++-- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs index 09b5873..00b0135 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs @@ -296,6 +296,12 @@ namespace System.Net.Http.Functional.Tests [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] public async Task GetAsyncWithRedirect_SetCookieContainer_CorrectCookiesSent() { + if (UseVersion == HttpVersion30) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/56870")] + return; + } + const string path1 = "/foo"; const string path2 = "/bar"; const string unusedPath = "/unused"; @@ -471,6 +477,12 @@ namespace System.Net.Http.Functional.Tests [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] public async Task GetAsync_Redirect_CookiesArePreserved() { + if (UseVersion == HttpVersion30) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/56870")] + return; + } + HttpClientHandler handler = CreateHttpClientHandler(); string loginPath = "/login/user"; @@ -601,6 +613,12 @@ namespace System.Net.Http.Functional.Tests [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] public async Task GetAsyncWithRedirect_ReceiveSetCookie_CookieSent() { + if (UseVersion == HttpVersion30) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/56870")] + return; + } + const string path1 = "/foo"; const string path2 = "/bar"; @@ -655,6 +673,12 @@ namespace System.Net.Http.Functional.Tests [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] public async Task GetAsyncWithBasicAuth_ReceiveSetCookie_CookieSent() { + if (UseVersion == HttpVersion30) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/56870")] + return; + } + if (IsWinHttpHandler) { // Issue https://github.com/dotnet/runtime/issues/24979 diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs index 8ec6cdb..cd530ae 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs @@ -238,6 +238,11 @@ namespace System.Net.Http // The server is requesting us fall back to an older HTTP version. throw new HttpRequestException(SR.net_http_retry_on_older_version, ex, RequestRetryType.RetryOnLowerHttpVersion); } + catch (QuicStreamAbortedException ex) when (ex.ErrorCode == (long)Http3ErrorCode.RequestRejected) + { + // The server is rejecting the request without processing it, retry it on a different connection. + throw new HttpRequestException(SR.net_http_request_aborted, ex, RequestRetryType.RetryOnConnectionFailure); + } catch (QuicStreamAbortedException ex) { // Our stream was reset. @@ -252,11 +257,10 @@ namespace System.Net.Http Exception abortException = _connection.Abort(ex); throw new HttpRequestException(SR.net_http_client_execution_error, abortException); } - catch (OperationCanceledException ex) - when (ex.CancellationToken == requestCancellationSource.Token) // It is possible for user's Content code to throw an unexpected OperationCanceledException. + // It is possible for user's Content code to throw an unexpected OperationCanceledException. + catch (OperationCanceledException ex) when (ex.CancellationToken == requestCancellationSource.Token) { // We're either observing GOAWAY, or the cancellationToken parameter has been canceled. - if (cancellationToken.IsCancellationRequested) { _stream.AbortWrite((long)Http3ErrorCode.RequestCancelled); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs index 8457218..14f444b 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs @@ -3176,7 +3176,6 @@ namespace System.Net.Http.Functional.Tests protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.Mock; } - [ActiveIssue("https://github.com/dotnet/runtime/issues/53093")] [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMsQuicSupported))] [Collection("NoParallelTests")] public sealed class SocketsHttpHandlerTest_Cookies_Http3_MsQuic : HttpClientHandlerTest_Cookies @@ -3186,7 +3185,6 @@ namespace System.Net.Http.Functional.Tests protected override QuicImplementationProvider UseQuicImplementationProvider => QuicImplementationProviders.MsQuic; } - [ActiveIssue("https://github.com/dotnet/runtime/issues/53093")] [ConditionalClass(typeof(HttpClientHandlerTestBase), nameof(IsMockQuicSupported))] [Collection("NoParallelTests")] public sealed class SocketsHttpHandlerTest_Cookies_Http3_Mock : HttpClientHandlerTest_Cookies diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs index 4cd21e5..a38a844 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicStreamTests.cs @@ -657,7 +657,7 @@ namespace System.Net.Quic.Tests { return; } - + const long expectedErrorCode = 1234; await RunClientServer( @@ -691,7 +691,7 @@ namespace System.Net.Quic.Tests { await using QuicStream stream = await connection.AcceptStreamAsync(); - async Task ReadUntilAborted() + async Task ReadUntilAborted() { var buffer = new byte[1024]; while (true) -- 2.7.4