diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs index 7fee0affc047c3..0d9b82b491d38d 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.MaxResponseHeadersLength.cs @@ -100,7 +100,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => await connection.SendResponseAsync(headers: new[] { new HttpHeaderData("Foo", new string('a', handler.MaxResponseHeadersLength * 1024)) }); } // Client can respond by closing/aborting the underlying stream while we are still sending the headers, ignore these exceptions - catch (IOException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode == SocketError.Shutdown) { } + catch (IOException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode is SocketError.Shutdown or SocketError.ConnectionReset or SocketError.ConnectionAborted) { } #if !WINHTTPHANDLER_TEST catch (QuicException ex) when (ex.QuicError == QuicError.StreamAborted && ex.ApplicationErrorCode == Http3ExcessiveLoad) { } #endif @@ -165,7 +165,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => await connection.SendResponseAsync(headers: headers); } // Client can respond by closing/aborting the underlying stream while we are still sending the headers, ignore these exceptions - catch (IOException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode == SocketError.Shutdown) { } + catch (IOException ex) when (ex.InnerException is SocketException se && se.SocketErrorCode is SocketError.Shutdown or SocketError.ConnectionReset or SocketError.ConnectionAborted) { } #if !WINHTTPHANDLER_TEST catch (QuicException ex) when (ex.QuicError == QuicError.StreamAborted && ex.ApplicationErrorCode == Http3ExcessiveLoad) {} #endif