默认超时时间2分钟
This commit is contained in:
parent
bd4133aa2c
commit
f95b19d024
@ -11,6 +11,7 @@ namespace FastGithub.Http
|
|||||||
public class HttpClient : HttpMessageInvoker
|
public class HttpClient : HttpMessageInvoker
|
||||||
{
|
{
|
||||||
private readonly DomainConfig domainConfig;
|
private readonly DomainConfig domainConfig;
|
||||||
|
private readonly TimeSpan defaltTimeout = TimeSpan.FromMinutes(2d);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// http客户端
|
/// http客户端
|
||||||
@ -50,7 +51,10 @@ namespace FastGithub.Http
|
|||||||
TlsSniPattern = this.domainConfig.GetTlsSniPattern(),
|
TlsSniPattern = this.domainConfig.GetTlsSniPattern(),
|
||||||
TlsIgnoreNameMismatch = this.domainConfig.TlsIgnoreNameMismatch
|
TlsIgnoreNameMismatch = this.domainConfig.TlsIgnoreNameMismatch
|
||||||
});
|
});
|
||||||
return base.SendAsync(request, cancellationToken);
|
|
||||||
|
using var timeoutTokenSource = new CancellationTokenSource(this.domainConfig.Timeout ?? defaltTimeout);
|
||||||
|
using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutTokenSource.Token);
|
||||||
|
return base.SendAsync(request, linkedTokenSource.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,9 +56,7 @@ namespace FastGithub.ReverseProxy
|
|||||||
{
|
{
|
||||||
var destinationPrefix = GetDestinationPrefix(host, domainConfig.Destination);
|
var destinationPrefix = GetDestinationPrefix(host, domainConfig.Destination);
|
||||||
var httpClient = this.httpClientFactory.CreateHttpClient(domainConfig);
|
var httpClient = this.httpClientFactory.CreateHttpClient(domainConfig);
|
||||||
var requestConfig = new ForwarderRequestConfig { Timeout = domainConfig.Timeout };
|
var error = await httpForwarder.SendAsync(context, destinationPrefix, httpClient);
|
||||||
|
|
||||||
var error = await httpForwarder.SendAsync(context, destinationPrefix, httpClient, requestConfig);
|
|
||||||
await HandleErrorAsync(context, error);
|
await HandleErrorAsync(context, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user