From 4268427ac36410452bcfee9fe51d7deeb0ef303d Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 27 Feb 2012 15:15:03 -0800 Subject: Some clean up in WebUtil, remove unused ServiceRequest function. --- OpenSim/Framework/WebUtil.cs | 78 ++++---------------------------------------- 1 file changed, 7 insertions(+), 71 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b761dfe..af25da9 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -63,77 +63,7 @@ namespace OpenSim.Framework // a "long" call for warning & debugging purposes public const int LongCallTime = 500; -// /// -// /// Send LLSD to an HTTP client in application/llsd+json form -// /// -// /// HTTP response to send the data in -// /// LLSD to send to the client -// public static void SendJSONResponse(OSHttpResponse response, OSDMap body) -// { -// byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body)); -// -// response.ContentEncoding = Encoding.UTF8; -// response.ContentLength = responseData.Length; -// response.ContentType = "application/llsd+json"; -// response.Body.Write(responseData, 0, responseData.Length); -// } -// -// /// -// /// Send LLSD to an HTTP client in application/llsd+xml form -// /// -// /// HTTP response to send the data in -// /// LLSD to send to the client -// public static void SendXMLResponse(OSHttpResponse response, OSDMap body) -// { -// byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body); -// -// response.ContentEncoding = Encoding.UTF8; -// response.ContentLength = responseData.Length; -// response.ContentType = "application/llsd+xml"; -// response.Body.Write(responseData, 0, responseData.Length); -// } - - /// - /// Make a GET or GET-like request to a web service that returns LLSD - /// or JSON data - /// - public static OSDMap ServiceRequest(string url, string httpVerb) - { - string errorMessage; - - try - { - HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); - request.Method = httpVerb; - - using (WebResponse response = request.GetResponse()) - { - using (Stream responseStream = response.GetResponseStream()) - { - try - { - string responseStr = responseStream.GetStreamString(); - OSD responseOSD = OSDParser.Deserialize(responseStr); - if (responseOSD.Type == OSDType.Map) - return (OSDMap)responseOSD; - else - errorMessage = "Response format was invalid."; - } - catch - { - errorMessage = "Failed to parse the response."; - } - } - } - } - catch (Exception ex) - { - m_log.Warn(httpVerb + " on URL " + url + " failed: " + ex.Message); - errorMessage = ex.Message; - } - - return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } }; - } + #region JSONRequest /// /// PUT JSON-encoded data to a web service that returns LLSD or @@ -303,6 +233,10 @@ namespace OpenSim.Framework return result; } + #endregion JSONRequest + + #region FormRequest + /// /// POST URL-encoded form data to a web service that returns LLSD or /// JSON data @@ -397,6 +331,8 @@ namespace OpenSim.Framework result["Message"] = OSD.FromString("Service request failed: " + msg); return result; } + + #endregion FormRequest #region Uri -- cgit v1.1 From aabbbb32ffd353ece2addf39c64f3ff3e15ca7d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 29 Feb 2012 23:45:14 +0000 Subject: Flick master up to 0.7.4 --- OpenSim/Framework/Servers/VersionInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index f30cb7a..7a5d715 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs @@ -29,7 +29,7 @@ namespace OpenSim { public class VersionInfo { - private const string VERSION_NUMBER = "0.7.3"; + private const string VERSION_NUMBER = "0.7.4"; private const Flavour VERSION_FLAVOUR = Flavour.Dev; public enum Flavour -- cgit v1.1 From 0007711eb5947d292f10325dd4af640ece79ea2d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 1 Mar 2012 03:23:10 +0000 Subject: Use a fully stubbed out MockConsole for unit tests rather than inheriting from CommandConsole. This is so that the static MainConsole.Instance doesn't retain references to methods registered by scene and other modules to service commands. This prevents the scene from being garbage collected at the end of a test. This is not the final thing preventing GC - next up is the timer started by SimStatsReporter that holds a reference to Scene that prevents end of test gc. --- OpenSim/Framework/Console/MockConsole.cs | 59 ++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index a29b370..4d8751f 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs @@ -29,6 +29,7 @@ using System; using System.Threading; using System.Collections.Generic; using System.Text; +using System.Xml; namespace OpenSim.Framework.Console { @@ -37,28 +38,42 @@ namespace OpenSim.Framework.Console /// Don't use this except for Unit Testing or you're in for a world of hurt when the /// sim gets to ReadLine /// - public class MockConsole : CommandConsole + public class MockConsole : ICommandConsole { - public MockConsole(string defaultPrompt) : base(defaultPrompt) - { - } - public override void Output(string text) - { - } - public override void Output(string text, string level) - { - } + private MockCommands m_commands = new MockCommands(); - public override string ReadLine(string p, bool isCommand, bool e) - { - //Thread.CurrentThread.Join(1000); - return string.Empty; - } - public override void UnlockOutput() - { - } - public override void LockOutput() - { - } + public ICommands Commands { get { return m_commands; } } + + public void Prompt() {} + + public void RunCommand(string cmd) {} + + public string ReadLine(string p, bool isCommand, bool e) { return ""; } + + public object ConsoleScene { get { return null; } } + + public void Output(string text, string level) {} + public void Output(string text) {} + public void OutputFormat(string format, params object[] components) {} + + public string CmdPrompt(string p) { return ""; } + public string CmdPrompt(string p, string def) { return ""; } + public string CmdPrompt(string p, List excludedCharacters) { return ""; } + public string CmdPrompt(string p, string def, List excludedCharacters) { return ""; } + + public string CmdPrompt(string prompt, string defaultresponse, List options) { return ""; } + + public string PasswdPrompt(string p) { return ""; } + } + + public class MockCommands : ICommands + { + public void FromXml(XmlElement root, CommandDelegate fn) {} + public List GetHelp(string[] cmd) { return null; } + public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {} + public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {} + public string[] FindNextOption(string[] cmd, bool term) { return null; } + public string[] Resolve(string[] cmd) { return null; } + public XmlElement GetXml(XmlDocument doc) { return null; } } -} +} \ No newline at end of file -- cgit v1.1