aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-05 06:05:25 +0000
committerTeravus Ovares2008-01-05 06:05:25 +0000
commitdb3edff5d5f1c9a31f377db77d1ac4e1fa685623 (patch)
tree5b2066a5556b3eff8f0152bdb3ce109b428081fe /OpenSim/Framework/Servers
parent* Added shell Messaging Server. Don't run the MessagingServer yet or you mig... (diff)
downloadopensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.zip
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.gz
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.bz2
opensim-SC-db3edff5d5f1c9a31f377db77d1ac4e1fa685623.tar.xz
* Applying jhurliman's LLSD login enablement patch.
* I'm keeping it deactivated until some issues are resolved. * I'm patching it in deactivated so the patch doesn't get outdated * I've deactivated it by commenting out the handler for the application/xml+llsd content type. * While I've tested this as much as possible on my setup and found the deactivated code doesn't cause any problems, consider this update experimental (event though it's deactivated)
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs75
-rw-r--r--OpenSim/Framework/Servers/LLSDMethod.cs33
2 files changed, 105 insertions, 3 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index af2b27c..b36cc8a 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -34,6 +34,7 @@ using System.Text;
34using System.Threading; 34using System.Threading;
35using System.Xml; 35using System.Xml;
36using Nwc.XmlRpc; 36using Nwc.XmlRpc;
37using libsecondlife.StructuredData;
37using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
38 39
39namespace OpenSim.Framework.Servers 40namespace OpenSim.Framework.Servers
@@ -43,6 +44,7 @@ namespace OpenSim.Framework.Servers
43 protected Thread m_workerThread; 44 protected Thread m_workerThread;
44 protected HttpListener m_httpListener; 45 protected HttpListener m_httpListener;
45 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 46 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
47 protected LLSDMethod m_llsdHandler = null;
46 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 48 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
47 protected uint m_port; 49 protected uint m_port;
48 protected bool m_ssl = false; 50 protected bool m_ssl = false;
@@ -90,6 +92,11 @@ namespace OpenSim.Framework.Servers
90 return false; 92 return false;
91 } 93 }
92 94
95 public bool SetLLSDHandler(LLSDMethod handler)
96 {
97 m_llsdHandler = handler;
98 return true;
99 }
93 100
94 public virtual void HandleRequest(Object stateinfo) 101 public virtual void HandleRequest(Object stateinfo)
95 { 102 {
@@ -136,7 +143,17 @@ namespace OpenSim.Framework.Servers
136 } 143 }
137 else 144 else
138 { 145 {
139 HandleXmlRpcRequests(request, response); 146 switch (request.ContentType)
147 {
148 //case "application/xml+llsd":
149 //HandleLLSDRequests(request, response);
150 //break;
151 case "text/xml":
152 case "application/xml":
153 default:
154 HandleXmlRpcRequests(request, response);
155 break;
156 }
140 } 157 }
141 } 158 }
142 159
@@ -242,7 +259,7 @@ namespace OpenSim.Framework.Servers
242 } 259 }
243 } 260 }
244 261
245 response.AddHeader("Content-type", "text/xml"); 262 response.ContentType = "text/xml";
246 263
247 byte[] buffer = Encoding.UTF8.GetBytes(responseString); 264 byte[] buffer = Encoding.UTF8.GetBytes(responseString);
248 265
@@ -263,6 +280,58 @@ namespace OpenSim.Framework.Servers
263 } 280 }
264 } 281 }
265 282
283 private void HandleLLSDRequests(HttpListenerRequest request, HttpListenerResponse response)
284 {
285 Stream requestStream = request.InputStream;
286
287 Encoding encoding = Encoding.UTF8;
288 StreamReader reader = new StreamReader(requestStream, encoding);
289
290 string requestBody = reader.ReadToEnd();
291 reader.Close();
292 requestStream.Close();
293
294 LLSD llsdRequest = null;
295 LLSD llsdResponse = null;
296
297 try { llsdRequest = LLSDParser.DeserializeXml(requestBody); }
298 catch (Exception ex) { MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message); }
299
300 if (llsdRequest != null && m_llsdHandler != null)
301 {
302 llsdResponse = m_llsdHandler(llsdRequest);
303 }
304 else
305 {
306 LLSDMap map = new LLSDMap();
307 map["reason"] = LLSD.FromString("LLSDRequest");
308 map["message"] = LLSD.FromString("No handler registered for LLSD Requests");
309 map["login"] = LLSD.FromString("false");
310 llsdResponse = map;
311 }
312
313 response.ContentType = "application/xml+llsd";
314
315 byte[] buffer = LLSDParser.SerializeXmlBytes(llsdResponse);
316
317 response.SendChunked = false;
318 response.ContentLength64 = buffer.Length;
319 response.ContentEncoding = Encoding.UTF8;
320
321 try
322 {
323 response.OutputStream.Write(buffer, 0, buffer.Length);
324 }
325 catch (Exception ex)
326 {
327 MainLog.Instance.Warn("HTTPD", "Error - " + ex.Message);
328 }
329 finally
330 {
331 response.OutputStream.Close();
332 }
333 }
334
266 public void HandleHTTPRequest(Hashtable keysvals, HttpListenerRequest request, HttpListenerResponse response) 335 public void HandleHTTPRequest(Hashtable keysvals, HttpListenerRequest request, HttpListenerResponse response)
267 { 336 {
268 // This is a test. There's a workable alternative.. as this way sucks. 337 // This is a test. There's a workable alternative.. as this way sucks.
@@ -436,4 +505,4 @@ namespace OpenSim.Framework.Servers
436 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path)); 505 m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
437 } 506 }
438 } 507 }
439} \ No newline at end of file 508}
diff --git a/OpenSim/Framework/Servers/LLSDMethod.cs b/OpenSim/Framework/Servers/LLSDMethod.cs
new file mode 100644
index 0000000..5cd225b
--- /dev/null
+++ b/OpenSim/Framework/Servers/LLSDMethod.cs
@@ -0,0 +1,33 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using libsecondlife.StructuredData;
29
30namespace OpenSim.Framework.Servers
31{
32 public delegate LLSD LLSDMethod(LLSD request);
33}