mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update Utility.Http.cs
This commit is contained in:
@@ -14,7 +14,7 @@ namespace TEngine
|
||||
public static partial class Http
|
||||
{
|
||||
/// <summary>
|
||||
/// GET请求与获取结果。
|
||||
/// GET请求与获取结果.
|
||||
/// </summary>
|
||||
public static async UniTask<string> Get(string url,float timeout = 5f)
|
||||
{
|
||||
@@ -24,13 +24,17 @@ namespace TEngine
|
||||
UnityWebRequest unityWebRequest = UnityWebRequest.Get(url);
|
||||
try
|
||||
{
|
||||
await unityWebRequest.SendWebRequest().WithCancellation(cts.Token);
|
||||
var (isCanceled, _) = await unityWebRequest.SendWebRequest().WithCancellation(cts.Token).SuppressCancellationThrow();
|
||||
if (isCanceled)
|
||||
{
|
||||
Log.Warning($"HttpGet {url} be canceled!");
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
if (ex.CancellationToken == cts.Token)
|
||||
{
|
||||
Debug.Log("HttpGet Timeout");
|
||||
Log.Debug("HttpGet Timeout");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user