Update Utility.Http.cs

This commit is contained in:
ALEXTANG
2023-07-13 19:34:30 +08:00
parent 95e4dd93a8
commit 79dc302f14

View File

@@ -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;
}
}