From 7a07731371486e82502fb928e123fcc966e4a5f0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Jun 2020 02:50:39 +0100 Subject: [PATCH] on simple cases no need to parse at all --- .../World/Estate/EstateConnector.cs | 14 ++---- .../AgentPreferencesConnector.cs | 18 ++----- .../AuthenticationServicesConnector.cs | 3 +- .../MuteList/MuteListServicesConnector.cs | 15 ++---- .../Presence/PresenceServicesConnector.cs | 49 +++++-------------- .../Simulation/SimulationServiceConnector.cs | 2 +- 6 files changed, 28 insertions(+), 73 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateConnector.cs b/OpenSim/Region/CoreModules/World/Estate/EstateConnector.cs index 8001c3ca7e..c7c502dda9 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateConnector.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateConnector.cs @@ -199,20 +199,16 @@ namespace OpenSim.Region.CoreModules.World.Estate string reply = SynchronousRestFormsRequester.MakeRequest("POST", url + "estate", reqString); + if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("RESULT")) + if (reply != string.Empty) { - if (replyData["RESULT"].ToString().ToLower() == "true") + int indx = reply.IndexOf("true", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) return true; - else - return false; + return false; } - else - m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field"); - } else m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply"); diff --git a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs index bd342fa798..5fe4a5df3b 100644 --- a/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs +++ b/OpenSim/Services/Connectors/AgentPreferences/AgentPreferencesConnector.cs @@ -154,20 +154,10 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - { - m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences reply data does not contain result field"); - } - + int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) + return true; + return false; } else m_log.DebugFormat("[AGENT PREFERENCES CONNECTOR]: StoreAgentPreferences received empty reply"); diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs index 0443f5a38b..ab13a673b9 100644 --- a/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs +++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServicesConnector.cs @@ -148,8 +148,7 @@ namespace OpenSim.Services.Connectors m_ServerURI + "/auth/plain", ServerUtils.BuildQueryString(sendData), m_Auth); - Dictionary replyData = ServerUtils.ParseXmlResponse( - reply); + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); if (replyData["Result"].ToString() != "Success") return false; diff --git a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs index 65666dd76e..9b95dd802c 100644 --- a/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs +++ b/OpenSim/Services/Connectors/MuteList/MuteListServicesConnector.cs @@ -157,17 +157,10 @@ namespace OpenSim.Services.Connectors string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString, m_Auth); if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} reply data does not contain result field", meth); + int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) + return true; + return false; } else m_log.DebugFormat("[MUTELIST CONNECTOR]: {0} received empty reply", meth); diff --git a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs index 89d64ca486..1f12b67793 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServicesConnector.cs @@ -111,18 +111,10 @@ namespace OpenSim.Services.Connectors m_Auth); if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent reply data does not contain result field"); - + int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) + return true; + return false; } else m_log.DebugFormat("[PRESENCE CONNECTOR]: LoginAgent received empty reply"); @@ -155,20 +147,13 @@ namespace OpenSim.Services.Connectors uri, reqString, m_Auth); + if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent reply data does not contain result field"); - + int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) + return true; + return false; } else m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent received empty reply"); @@ -202,18 +187,10 @@ namespace OpenSim.Services.Connectors m_Auth); if (reply != string.Empty) { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents reply data does not contain result field"); - + int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); + if (indx > 0) + return true; + return false; } else m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutRegionAgents received empty reply"); diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 18c949e2e9..aa82318d7f 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -469,7 +469,7 @@ namespace OpenSim.Services.Connectors.Simulation try { - OSDMap args = new OSDMap(2); + OSDMap args = new OSDMap(16); args["sog"] = OSD.FromString(sog.ToXml2()); args["extra"] = OSD.FromString(sog.ExtraToXmlString());