From d92ac1f892a7f9c00561db6541671f25f3972eed Mon Sep 17 00:00:00 2001 From: Radek Zikmund <32671551+rzikm@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:14:09 +0200 Subject: [PATCH] Fix SocketsHttpHandlerTest_HttpClientHandlerTest_Http3.ReadAsStreamAsync_Cancellation data race (#101428) * Fix SocketsHttpHandlerTest_HttpClientHandlerTest_Http3.ReadAsStreamAsync_Cancellation data race * Fix build --- .../tests/System/Net/Http/HttpClientHandlerTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs index 0ffd0d4ae82ed..7c3d3f385d0bd 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs @@ -6,6 +6,9 @@ using System.Linq; using System.Net.Http.Headers; using System.Net.Sockets; +#if !NETFRAMEWORK +using System.Net.Quic; +#endif using System.Net.Test.Common; using System.Security.Authentication; using System.Security.Cryptography; @@ -1396,6 +1399,12 @@ await server.AcceptConnectionAsync(async connection => await connection.SendResponseAsync(HttpStatusCode.OK, headers: new HttpHeaderData[] { new HttpHeaderData("Transfer-Encoding", "chunked") }, isFinal: false); await connection.SendResponseBodyAsync("1\r\nh\r\n", false); } +#if !NETFRAMEWORK + catch (QuicException ex) when (ex.ApplicationErrorCode == 0x10c /*H3_REQUEST_CANCELLED*/) + { + // The request was cancelled before we sent the body, ignore + } +#endif catch (IOException ex) { // when testing in the browser, we are using the WebSocket for the loopback