Skip to content

Commit

Permalink
chore: sync main to dev (#2460)
Browse files Browse the repository at this point in the history
  • Loading branch information
aixaCode authored Oct 16, 2024
1 parent af481bc commit 1ccf8ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public async UniTask UrlReachabilityResolveAsync(IWebRequestController webReques
isReachable = false;
this.url = url;

isReachable = await webRequestController.IsReachableAsync(reportData, URLAddress.FromString(this.url), ct);
isReachable = await webRequestController.IsHeadReachableAsync(reportData, URLAddress.FromString(this.url), ct);
//This is needed because some servers might not handle HEAD requests correctly and return 404 errors, even thou they are perfectly
if (!isReachable)
isReachable = await webRequestController.IsGetReachableAsync(reportData, URLAddress.FromString(this.url), ct);

ReportHub.Log(ReportCategory.MEDIA_STREAM, $"Resource <{url}> isReachable = <{isReachable}>");

status = Status.Resolved;
Expand Down
17 changes: 15 additions & 2 deletions Explorer/Assets/DCL/WebRequests/WebRequestControllerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static UniTask<TResult> HeadAsync<TOp, TResult>(
WebRequestSignInfo? signInfo = null) where TOp: struct, IWebRequestOp<GenericHeadRequest, TResult> =>
controller.SendAsync<GenericHeadRequest, GenericHeadArguments, TOp, TResult>(HEAD_GENERIC, commonArguments, arguments, webRequestOp, ct, reportCategory, headersInfo, signInfo);

public static async UniTask<bool> IsReachableAsync(this IWebRequestController controller, ReportData reportData, URLAddress url, CancellationToken ct)
public static async UniTask<bool> IsHeadReachableAsync(this IWebRequestController controller, ReportData reportData, URLAddress url, CancellationToken ct)
{
await UniTask.SwitchToMainThread();

Expand All @@ -168,7 +168,6 @@ public static async UniTask<bool> IsReachableAsync(this IWebRequestController co
case WebRequestUtils.NOT_FOUND:
return false;
}

// Assume everything else means that there is such an endpoint for Non-HEAD ops
return true;
}
Expand All @@ -177,6 +176,20 @@ public static async UniTask<bool> IsReachableAsync(this IWebRequestController co
return true;
}

public static async UniTask<bool> IsGetReachableAsync(this IWebRequestController controller, ReportData reportData, URLAddress url, CancellationToken ct)
{
await UniTask.SwitchToMainThread();

try { await GetAsync<WebRequestUtils.NoOp<GenericGetRequest>, WebRequestUtils.NoResult>(controller, new CommonArguments(url), new WebRequestUtils.NoOp<GenericGetRequest>(), ct, reportData); }
catch (UnityWebRequestException)
{
return false;
}

return true;
}


/// <summary>
/// Make a request that is optimized for texture creation
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Explorer/Assets/Scripts/Global/Dynamic/RealmController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public async UniTask RestartRealmAsync(CancellationToken ct)
}

public async UniTask<bool> IsReachableAsync(URLDomain realm, CancellationToken ct) =>
await webRequestController.IsReachableAsync(ReportCategory.REALM, realm.Append(new URLPath("/about")), ct);
await webRequestController.IsHeadReachableAsync(ReportCategory.REALM, realm.Append(new URLPath("/about")), ct);

public async UniTask<AssetPromise<SceneEntityDefinition, GetSceneDefinition>[]> WaitForFixedScenePromisesAsync(CancellationToken ct)
{
Expand Down

0 comments on commit 1ccf8ac

Please sign in to comment.