diff --git a/FastGithub.Http/HttpClientHandler.cs b/FastGithub.Http/HttpClientHandler.cs index e55061b..d2c1447 100644 --- a/FastGithub.Http/HttpClientHandler.cs +++ b/FastGithub.Http/HttpClientHandler.cs @@ -126,9 +126,7 @@ namespace FastGithub.Http /// private void InterceptRequestException(HttpRequestMessage request, HttpRequestException exception) { - if (request.RequestUri == null || - exception.InnerException is not SocketException socketException || - socketException.SocketErrorCode != SocketError.TimedOut) + if (request.RequestUri == null || IsTimedOutSocketError(exception) == false) { return; } @@ -142,6 +140,21 @@ namespace FastGithub.Http { this.domainResolver.FlushDomain(new DnsEndPoint(request.Headers.Host, request.RequestUri.Port)); } + + + static bool IsTimedOutSocketError(HttpRequestException exception) + { + var inner = exception.InnerException; + while (inner != null) + { + if (inner is SocketException socketException && socketException.SocketErrorCode == SocketError.TimedOut) + { + return true; + } + inner = inner.InnerException; + } + return false; + } } ///