Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions http/QueryParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;

namespace RESTClient {
public class QueryParams {
Expand All @@ -26,8 +27,8 @@ public override string ToString() {
}
StringBuilder sb = new StringBuilder("?");
foreach (KeyValuePair<string, string> 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);
Expand Down
9 changes: 2 additions & 7 deletions http/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@ public void AddHeaders(Dictionary<string, string> headers) {

public void AddBody(string text, string contentType = "text/plain; charset=UTF-8") {
byte[] bytes = Encoding.UTF8.GetBytes(text);
this.AddBody(bytes, contentType, false);
this.AddBody(bytes, contentType);
}

public void AddBody(byte[] bytes, string contentType) {
this.AddBody(bytes, contentType, false);
}

public void AddBody(byte[] bytes, string contentType, bool isChunked) {
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;
}
Expand All @@ -60,7 +55,7 @@ public void AddBody(byte[] bytes, string contentType, bool isChunked) {
}
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) {
Expand Down