From 305c4aaa0757cc6f961962518462b8e7ac0267a8 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 9 Jul 2020 22:17:49 +0900 Subject: [PATCH] fix UnityWebRequestException String access is not supported #110 --- .../Plugins/UniTask/Runtime/UnityWebRequestException.cs | 5 ++++- src/UniTask/Assets/Scenes/SandboxMain.cs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs index efd1565..9a164ab 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityWebRequestException.cs @@ -33,7 +33,10 @@ namespace Cysharp.Threading.Tasks this.ResponseCode = unityWebRequest.responseCode; if (UnityWebRequest.downloadHandler != null) { - this.Text = unityWebRequest.downloadHandler.text; + if (unityWebRequest.downloadHandler is DownloadHandlerBuffer dhb) + { + this.Text = dhb.text; + } } } diff --git a/src/UniTask/Assets/Scenes/SandboxMain.cs b/src/UniTask/Assets/Scenes/SandboxMain.cs index f84ced7..a96fb90 100644 --- a/src/UniTask/Assets/Scenes/SandboxMain.cs +++ b/src/UniTask/Assets/Scenes/SandboxMain.cs @@ -476,8 +476,8 @@ public class SandboxMain : MonoBehaviour async UniTaskVoid Start() { - var url = "http://fooooooooooooooooooooooooooooooooooo.com"; - var webRequestAsyncOperation = UnityWebRequest.Head(url).SendWebRequest(); + var url = "http://google.com/404"; + var webRequestAsyncOperation = UnityWebRequest.Get(url).SendWebRequest(); await webRequestAsyncOperation.ToUniTask(); //PlayerLoopInfo.Inject();