Skip to content

Commit e5eb0d0

Browse files
com.utilities.rest 5.0.4
- Fix response body and data decode, added json parsing fallback
1 parent aeabcda commit e5eb0d0

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Runtime/Response.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,16 @@ public string ToString(string methodName)
223223
Headers.TryGetValue("Content-Type", out var contentType) &&
224224
contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
225225
{
226-
debugMessageObject["response"]["body"] = JToken.Parse(Encoding.UTF8.GetString(Data));
226+
var decoded = Encoding.UTF8.GetString(Data);
227+
228+
try
229+
{
230+
debugMessageObject["response"]["body"] = JToken.Parse(decoded);
231+
}
232+
catch
233+
{
234+
debugMessageObject["response"]["body"] = decoded;
235+
}
227236
}
228237
}
229238
else

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Utilities.Rest",
44
"description": "This package contains useful RESTful utilities for the Unity Game Engine.",
55
"keywords": [],
6-
"version": "5.0.3",
6+
"version": "5.0.4",
77
"unity": "2021.3",
88
"documentationUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest#documentation",
99
"changelogUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest/releases",

0 commit comments

Comments
 (0)