From b9c11299d520ba7476b158a6cb69e7476328d7ae Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 4 Aug 2023 01:36:41 +0200 Subject: [PATCH] forward innerException's error code to retryable HttpRequestException (#89963) If we are doing a retry because of a protocol error, or some other HttpIOException, we should forward the error code to the retryable HttpRequestException --- .../src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index 8f3093de88e2c..2b2a1d01d8902 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -2205,7 +2205,7 @@ internal void Trace(int streamId, string message, [CallerMemberName] string? mem [DoesNotReturn] private static void ThrowRetry(string message, Exception? innerException = null) => - throw new HttpRequestException(HttpRequestError.Unknown, message, innerException, RequestRetryType.RetryOnConnectionFailure); + throw new HttpRequestException((innerException as HttpIOException)?.HttpRequestError ?? HttpRequestError.Unknown, message, innerException, RequestRetryType.RetryOnConnectionFailure); private static Exception GetRequestAbortedException(Exception? innerException = null) => innerException as HttpIOException ?? new IOException(SR.net_http_request_aborted, innerException);