mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Avoid deserialisation JSON request content when error is not present (or not relevant)
This commit is contained in:
@ -171,9 +171,13 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
WebRequest?.Abort();
|
WebRequest?.Abort();
|
||||||
|
|
||||||
|
// in the case of a cancellation we don't care about whether there's an error in the response.
|
||||||
|
if (!(e is OperationCanceledException))
|
||||||
|
{
|
||||||
string responseString = WebRequest?.GetResponseString();
|
string responseString = WebRequest?.GetResponseString();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(responseString))
|
// naive check whether there's an error in the response to avoid unnecessary JSON deserialisation.
|
||||||
|
if (!string.IsNullOrEmpty(responseString) && responseString.Contains(@"""error"""))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -186,6 +190,7 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
|
Logger.Log($@"Failing request {this} ({e})", LoggingTarget.Network);
|
||||||
pendingFailure = () => TriggerFailure(e);
|
pendingFailure = () => TriggerFailure(e);
|
||||||
|
Reference in New Issue
Block a user