aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorTeravus Ovares2008-09-27 09:42:31 +0000
committerTeravus Ovares2008-09-27 09:42:31 +0000
commit85b280385fd7400da8bc721131d25eee9fd7f8da (patch)
treef0fdba12f4442e01c9a3032c6c0b8881194f3509 /OpenSim/Framework/Servers
parentUpdate unit tests (diff)
downloadopensim-SC_OLD-85b280385fd7400da8bc721131d25eee9fd7f8da.zip
opensim-SC_OLD-85b280385fd7400da8bc721131d25eee9fd7f8da.tar.gz
opensim-SC_OLD-85b280385fd7400da8bc721131d25eee9fd7f8da.tar.bz2
opensim-SC_OLD-85b280385fd7400da8bc721131d25eee9fd7f8da.tar.xz
* This is the very very early beginnings of an EventQueue:get module.
* This won't function yet as far as the client can tell.. because it doesn't respond to the first query with a 200 message. * We have to figure out how to encode those binary values in the example code in the module... * Committing this so we have a start point. Will continue to work on this more today.
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHTTPHandler.cs42
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs61
-rw-r--r--OpenSim/Framework/Servers/RestHTTPHandler.cs57
3 files changed, 155 insertions, 5 deletions
diff --git a/OpenSim/Framework/Servers/BaseHTTPHandler.cs b/OpenSim/Framework/Servers/BaseHTTPHandler.cs
new file mode 100644
index 0000000..a7c3562
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseHTTPHandler.cs
@@ -0,0 +1,42 @@
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 System;
29using System.Collections;
30
31namespace OpenSim.Framework.Servers
32{
33 public abstract class BaseHTTPHandler : BaseRequestHandler, IGenericHTTPHandler
34 {
35 public abstract Hashtable Handle(string path, Hashtable Request);
36
37 protected BaseHTTPHandler(string httpMethod, string path)
38 : base(httpMethod, path)
39 {
40 }
41 }
42} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index ae07895..24bba2b 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -361,9 +361,57 @@ namespace OpenSim.Framework.Servers
361 361
362 buffer = streamedRequestHandler.Handle(path, request.InputStream, request, response); 362 buffer = streamedRequestHandler.Handle(path, request.InputStream, request, response);
363 } 363 }
364 else if (requestHandler is IGenericHTTPHandler)
365 {
366 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
367 Stream requestStream = request.InputStream;
368
369 Encoding encoding = Encoding.UTF8;
370 StreamReader reader = new StreamReader(requestStream, encoding);
371
372 string requestBody = reader.ReadToEnd();
373
374
375 reader.Close();
376 requestStream.Close();
377
378 Hashtable keysvals = new Hashtable();
379 Hashtable headervals = new Hashtable();
380 string host = String.Empty;
381
382 string[] querystringkeys = request.QueryString.AllKeys;
383 string[] rHeaders = request.Headers.AllKeys;
384
385
386 foreach (string queryname in querystringkeys)
387 {
388 keysvals.Add(queryname, request.QueryString[queryname]);
389 }
390
391 foreach (string headername in rHeaders)
392 {
393 //m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]);
394 headervals[headername] = request.Headers[headername];
395 }
396
397 if (headervals.Contains("Host"))
398 {
399 host = (string)headervals["Host"];
400 }
401 keysvals.Add("requestbody",requestBody);
402 if (keysvals.Contains("method"))
403 {
404 //m_log.Warn("[HTTP]: Contains Method");
405 string method = (string)keysvals["method"];
406 //m_log.Warn("[HTTP]: " + requestBody);
407
408 }
409 DoHTTPGruntWork(HTTPRequestHandler.Handle(path,keysvals), response);
410 return;
411 }
364 else 412 else
365 { 413 {
366 IStreamHandler streamHandler = (IStreamHandler) requestHandler; 414 IStreamHandler streamHandler = (IStreamHandler)requestHandler;
367 415
368 using (MemoryStream memoryStream = new MemoryStream()) 416 using (MemoryStream memoryStream = new MemoryStream())
369 { 417 {
@@ -943,6 +991,9 @@ namespace OpenSim.Framework.Servers
943 string responseString = (string)responsedata["str_response_string"]; 991 string responseString = (string)responsedata["str_response_string"];
944 string contentType = (string)responsedata["content_type"]; 992 string contentType = (string)responsedata["content_type"];
945 993
994 if (responsedata.ContainsKey("keepalive"))
995 response.KeepAlive = true;
996
946 //Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this 997 //Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this
947 //and should check for NullReferenceExceptions 998 //and should check for NullReferenceExceptions
948 999
@@ -951,10 +1002,9 @@ namespace OpenSim.Framework.Servers
951 contentType = "text/html"; 1002 contentType = "text/html";
952 } 1003 }
953 1004
954 // We're forgoing the usual error status codes here because the client 1005 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that
955 // ignores anything but 200 and 301 1006
956 1007 response.StatusCode = responsecode;
957 response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
958 1008
959 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) 1009 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
960 { 1010 {
@@ -978,6 +1028,7 @@ namespace OpenSim.Framework.Servers
978 response.SendChunked = false; 1028 response.SendChunked = false;
979 response.ContentLength64 = buffer.Length; 1029 response.ContentLength64 = buffer.Length;
980 response.ContentEncoding = Encoding.UTF8; 1030 response.ContentEncoding = Encoding.UTF8;
1031
981 1032
982 try 1033 try
983 { 1034 {
diff --git a/OpenSim/Framework/Servers/RestHTTPHandler.cs b/OpenSim/Framework/Servers/RestHTTPHandler.cs
new file mode 100644
index 0000000..2974c56
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestHTTPHandler.cs
@@ -0,0 +1,57 @@
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 System;
29using System.Collections;
30
31namespace OpenSim.Framework.Servers
32{
33 public class RestHTTPHandler : BaseHTTPHandler
34 {
35 private GenericHTTPMethod m_dhttpMethod;
36
37 public GenericHTTPMethod Method
38 {
39 get { return m_dhttpMethod; }
40 }
41
42 public override Hashtable Handle(string path, Hashtable request)
43 {
44
45 string param = GetParam(path);
46 request.Add("param", param);
47 request.Add("path", path);
48 return m_dhttpMethod(request);
49 }
50
51 public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod)
52 : base(httpMethod, path)
53 {
54 m_dhttpMethod = dhttpMethod;
55 }
56 }
57}