From 70161f26c16832c5b89f2edc362344fa743cb2b0 Mon Sep 17 00:00:00 2001 From: Keizo Fujiwara Date: Sat, 10 Oct 2020 22:33:48 +0900 Subject: [PATCH 1/3] Update WWW with UnityWebRequest --- http/QueryParams.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http/QueryParams.cs b/http/QueryParams.cs index f08ce18..e96a80e 100644 --- a/http/QueryParams.cs +++ b/http/QueryParams.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using UnityEngine; +using UnityEngine.Networking; namespace RESTClient { public class QueryParams { @@ -26,8 +27,8 @@ public override string ToString() { } StringBuilder sb = new StringBuilder("?"); foreach (KeyValuePair param in parameters) { - string key = WWW.EscapeURL(param.Key); - string value = WWW.EscapeURL(param.Value); + string key = UnityWebRequest.EscapeURL(param.Key); + string value = UnityWebRequest.EscapeURL(param.Value); sb.Append(key + "=" + value + "&"); } sb.Remove(sb.Length - 1, 1); From 22364564387e00b8dc15b7216dc4a092853e3bda Mon Sep 17 00:00:00 2001 From: Keizo Fujiwara Date: Sun, 29 Nov 2020 00:30:58 +0900 Subject: [PATCH 2/3] Unsupport chunkedTransfer --- http/RestRequest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/http/RestRequest.cs b/http/RestRequest.cs index d316e2b..1b2c0dd 100644 --- a/http/RestRequest.cs +++ b/http/RestRequest.cs @@ -43,12 +43,11 @@ public void AddBody(byte[] bytes, string contentType) { this.AddBody(bytes, contentType, false); } - public void AddBody(byte[] bytes, string contentType, bool isChunked) { + public void AddBody(byte[] bytes, string contentType) { if (Request.uploadHandler != null) { Debug.LogWarning("Request body can only be set once"); return; } - Request.chunkedTransfer = isChunked; Request.uploadHandler = new UploadHandlerRaw(bytes); Request.uploadHandler.contentType = contentType; } From 6cccba78b1e53e59cae5ffc6e7c3c75c18374ebb Mon Sep 17 00:00:00 2001 From: Keizo Fujiwara Date: Sun, 29 Nov 2020 00:41:39 +0900 Subject: [PATCH 3/3] Remove methods using chunkedTransfer --- http/RestRequest.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/http/RestRequest.cs b/http/RestRequest.cs index 1b2c0dd..f67ecf5 100644 --- a/http/RestRequest.cs +++ b/http/RestRequest.cs @@ -36,11 +36,7 @@ public void AddHeaders(Dictionary headers) { public void AddBody(string text, string contentType = "text/plain; charset=UTF-8") { byte[] bytes = Encoding.UTF8.GetBytes(text); - this.AddBody(bytes, contentType, false); - } - - public void AddBody(byte[] bytes, string contentType) { - this.AddBody(bytes, contentType, false); + this.AddBody(bytes, contentType); } public void AddBody(byte[] bytes, string contentType) { @@ -59,7 +55,7 @@ public void AddBody(byte[] bytes, string contentType) { } string jsonString = JsonUtility.ToJson(data); byte[] bytes = Encoding.UTF8.GetBytes(jsonString); - this.AddBody(bytes, contentType, false); + this.AddBody(bytes, contentType); } public virtual void AddQueryParam(string key, string value, bool shouldUpdateRequestUrl = false) {