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