aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Console/MockConsole.cs59
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs2
-rw-r--r--OpenSim/Framework/WebUtil.cs78
3 files changed, 45 insertions, 94 deletions
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;
29using System.Threading; 29using System.Threading;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using System.Xml;
32 33
33namespace OpenSim.Framework.Console 34namespace OpenSim.Framework.Console
34{ 35{
@@ -37,28 +38,42 @@ namespace OpenSim.Framework.Console
37 /// Don't use this except for Unit Testing or you're in for a world of hurt when the 38 /// Don't use this except for Unit Testing or you're in for a world of hurt when the
38 /// sim gets to ReadLine 39 /// sim gets to ReadLine
39 /// </summary> 40 /// </summary>
40 public class MockConsole : CommandConsole 41 public class MockConsole : ICommandConsole
41 { 42 {
42 public MockConsole(string defaultPrompt) : base(defaultPrompt) 43 private MockCommands m_commands = new MockCommands();
43 {
44 }
45 public override void Output(string text)
46 {
47 }
48 public override void Output(string text, string level)
49 {
50 }
51 44
52 public override string ReadLine(string p, bool isCommand, bool e) 45 public ICommands Commands { get { return m_commands; } }
53 { 46
54 //Thread.CurrentThread.Join(1000); 47 public void Prompt() {}
55 return string.Empty; 48
56 } 49 public void RunCommand(string cmd) {}
57 public override void UnlockOutput() 50
58 { 51 public string ReadLine(string p, bool isCommand, bool e) { return ""; }
59 } 52
60 public override void LockOutput() 53 public object ConsoleScene { get { return null; } }
61 { 54
62 } 55 public void Output(string text, string level) {}
56 public void Output(string text) {}
57 public void OutputFormat(string format, params object[] components) {}
58
59 public string CmdPrompt(string p) { return ""; }
60 public string CmdPrompt(string p, string def) { return ""; }
61 public string CmdPrompt(string p, List<char> excludedCharacters) { return ""; }
62 public string CmdPrompt(string p, string def, List<char> excludedCharacters) { return ""; }
63
64 public string CmdPrompt(string prompt, string defaultresponse, List<string> options) { return ""; }
65
66 public string PasswdPrompt(string p) { return ""; }
67 }
68
69 public class MockCommands : ICommands
70 {
71 public void FromXml(XmlElement root, CommandDelegate fn) {}
72 public List<string> GetHelp(string[] cmd) { return null; }
73 public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {}
74 public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {}
75 public string[] FindNextOption(string[] cmd, bool term) { return null; }
76 public string[] Resolve(string[] cmd) { return null; }
77 public XmlElement GetXml(XmlDocument doc) { return null; }
63 } 78 }
64} 79} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index b2bb962..63ec257 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,7 +29,7 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.7.3CM"; 32 private const string VERSION_NUMBER = "0.7.4CM";
33 private const Flavour VERSION_FLAVOUR = Flavour.Dev; 33 private const Flavour VERSION_FLAVOUR = Flavour.Dev;
34 34
35 public enum Flavour 35 public enum Flavour
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 854f310..f90df12 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -63,77 +63,7 @@ namespace OpenSim.Framework
63 // a "long" call for warning & debugging purposes 63 // a "long" call for warning & debugging purposes
64 public const int LongCallTime = 500; 64 public const int LongCallTime = 500;
65 65
66// /// <summary> 66 #region JSONRequest
67// /// Send LLSD to an HTTP client in application/llsd+json form
68// /// </summary>
69// /// <param name="response">HTTP response to send the data in</param>
70// /// <param name="body">LLSD to send to the client</param>
71// public static void SendJSONResponse(OSHttpResponse response, OSDMap body)
72// {
73// byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body));
74//
75// response.ContentEncoding = Encoding.UTF8;
76// response.ContentLength = responseData.Length;
77// response.ContentType = "application/llsd+json";
78// response.Body.Write(responseData, 0, responseData.Length);
79// }
80//
81// /// <summary>
82// /// Send LLSD to an HTTP client in application/llsd+xml form
83// /// </summary>
84// /// <param name="response">HTTP response to send the data in</param>
85// /// <param name="body">LLSD to send to the client</param>
86// public static void SendXMLResponse(OSHttpResponse response, OSDMap body)
87// {
88// byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body);
89//
90// response.ContentEncoding = Encoding.UTF8;
91// response.ContentLength = responseData.Length;
92// response.ContentType = "application/llsd+xml";
93// response.Body.Write(responseData, 0, responseData.Length);
94// }
95
96 /// <summary>
97 /// Make a GET or GET-like request to a web service that returns LLSD
98 /// or JSON data
99 /// </summary>
100 public static OSDMap ServiceRequest(string url, string httpVerb)
101 {
102 string errorMessage;
103
104 try
105 {
106 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
107 request.Method = httpVerb;
108
109 using (WebResponse response = request.GetResponse())
110 {
111 using (Stream responseStream = response.GetResponseStream())
112 {
113 try
114 {
115 string responseStr = responseStream.GetStreamString();
116 OSD responseOSD = OSDParser.Deserialize(responseStr);
117 if (responseOSD.Type == OSDType.Map)
118 return (OSDMap)responseOSD;
119 else
120 errorMessage = "Response format was invalid.";
121 }
122 catch
123 {
124 errorMessage = "Failed to parse the response.";
125 }
126 }
127 }
128 }
129 catch (Exception ex)
130 {
131 m_log.Warn(httpVerb + " on URL " + url + " failed: " + ex.Message);
132 errorMessage = ex.Message;
133 }
134
135 return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } };
136 }
137 67
138 /// <summary> 68 /// <summary>
139 /// PUT JSON-encoded data to a web service that returns LLSD or 69 /// PUT JSON-encoded data to a web service that returns LLSD or
@@ -304,6 +234,10 @@ namespace OpenSim.Framework
304 return result; 234 return result;
305 } 235 }
306 236
237 #endregion JSONRequest
238
239 #region FormRequest
240
307 /// <summary> 241 /// <summary>
308 /// POST URL-encoded form data to a web service that returns LLSD or 242 /// POST URL-encoded form data to a web service that returns LLSD or
309 /// JSON data 243 /// JSON data
@@ -398,6 +332,8 @@ namespace OpenSim.Framework
398 result["Message"] = OSD.FromString("Service request failed: " + msg); 332 result["Message"] = OSD.FromString("Service request failed: " + msg);
399 return result; 333 return result;
400 } 334 }
335
336 #endregion FormRequest
401 337
402 #region Uri 338 #region Uri
403 339