递归查找TimedOut异常
This commit is contained in:
parent
c066e153be
commit
1770955d33
@ -126,9 +126,7 @@ namespace FastGithub.Http
|
|||||||
/// <param name="exception"></param>
|
/// <param name="exception"></param>
|
||||||
private void InterceptRequestException(HttpRequestMessage request, HttpRequestException exception)
|
private void InterceptRequestException(HttpRequestMessage request, HttpRequestException exception)
|
||||||
{
|
{
|
||||||
if (request.RequestUri == null ||
|
if (request.RequestUri == null || IsTimedOutSocketError(exception) == false)
|
||||||
exception.InnerException is not SocketException socketException ||
|
|
||||||
socketException.SocketErrorCode != SocketError.TimedOut)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,6 +140,21 @@ namespace FastGithub.Http
|
|||||||
{
|
{
|
||||||
this.domainResolver.FlushDomain(new DnsEndPoint(request.Headers.Host, request.RequestUri.Port));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user