change region objecthandlers
parent
473dba93e8
commit
05f098be56
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -47,88 +48,87 @@ using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Server.Handlers.Simulation
|
namespace OpenSim.Server.Handlers.Simulation
|
||||||
{
|
{
|
||||||
public class ObjectHandler
|
public class ObjectSimpleHandler : SimpleStreamHandler
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private ISimulationService m_SimulationService;
|
private ISimulationService m_SimulationService;
|
||||||
|
protected bool m_Proxy = false;
|
||||||
|
|
||||||
public ObjectHandler() { }
|
public ObjectSimpleHandler(ISimulationService service) : base("/object")
|
||||||
|
|
||||||
public ObjectHandler(ISimulationService sim)
|
|
||||||
{
|
{
|
||||||
m_SimulationService = sim;
|
m_SimulationService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable Handler(Hashtable request)
|
protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
//m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
|
httpResponse.KeepAlive = false;
|
||||||
|
|
||||||
//m_log.Debug("---------------------------");
|
if (m_SimulationService == null)
|
||||||
//m_log.Debug(" >> uri=" + request["uri"]);
|
|
||||||
//m_log.Debug(" >> content-type=" + request["content-type"]);
|
|
||||||
//m_log.Debug(" >> http-method=" + request["http-method"]);
|
|
||||||
//m_log.Debug("---------------------------\n");
|
|
||||||
|
|
||||||
Culture.SetCurrentCulture();
|
|
||||||
|
|
||||||
Hashtable responsedata = new Hashtable();
|
|
||||||
responsedata["content_type"] = "text/html";
|
|
||||||
|
|
||||||
UUID objectID;
|
|
||||||
UUID regionID;
|
|
||||||
string action;
|
|
||||||
if (!Utils.GetParams((string)request["uri"], out objectID, out regionID, out action))
|
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[OBJECT HANDLER]: Invalid parameters for object message {0}", request["uri"]);
|
httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
responsedata["int_response_code"] = 404;
|
httpResponse.RawBuffer = Util.UTF8.GetBytes("false");
|
||||||
responsedata["str_response_string"] = "false";
|
|
||||||
|
|
||||||
return responsedata;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Next, let's parse the verb
|
|
||||||
string method = (string)request["http-method"];
|
|
||||||
if (method.Equals("POST"))
|
|
||||||
{
|
|
||||||
DoObjectPost(request, responsedata, regionID);
|
|
||||||
return responsedata;
|
|
||||||
}
|
|
||||||
//else if (method.Equals("DELETE"))
|
|
||||||
//{
|
|
||||||
// DoObjectDelete(request, responsedata, agentID, action, regionHandle);
|
|
||||||
// return responsedata;
|
|
||||||
//}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[OBJECT HANDLER]: method {0} not supported in object message", method);
|
|
||||||
responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
|
|
||||||
responsedata["str_response_string"] = "Method not allowed";
|
|
||||||
|
|
||||||
return responsedata;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[OBJECT HANDLER]: Caught exception {0}", e.StackTrace);
|
|
||||||
responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
|
|
||||||
responsedata["str_response_string"] = "Internal server error";
|
|
||||||
|
|
||||||
return responsedata;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
|
|
||||||
{
|
|
||||||
OSDMap args = Utils.GetOSDMap((string)request["body"]);
|
|
||||||
if (args == null)
|
|
||||||
{
|
|
||||||
responsedata["int_response_code"] = 400;
|
|
||||||
responsedata["str_response_string"] = "false";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* this things are ignored
|
||||||
|
if (!Utils.GetParams(httpRequest.UriPath, out UUID objectID, out UUID regionID, out string action))
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[OBJECT HANDLER]: Invalid parameters for object message {0}", httpRequest.UriPath);
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch (httpRequest.HttpMethod)
|
||||||
|
{
|
||||||
|
case "POST":
|
||||||
|
{
|
||||||
|
OSDMap args = Deserialize(httpRequest);
|
||||||
|
if (args == null)
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
httpResponse.RawBuffer = Util.UTF8.GetBytes("false");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DoObjectPost(args, httpResponse);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "DELETE":
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
httpResponse.StatusCode = (int)HttpStatusCode.MethodNotAllowed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private OSDMap Deserialize(IOSHttpRequest httpRequest)
|
||||||
|
{
|
||||||
|
Stream inputStream = httpRequest.InputStream;
|
||||||
|
Stream innerStream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip"))
|
||||||
|
{
|
||||||
|
innerStream = inputStream;
|
||||||
|
inputStream = new GZipStream(innerStream, CompressionMode.Decompress);
|
||||||
|
}
|
||||||
|
return (OSDMap)OSDParser.DeserializeJson(inputStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (innerStream != null)
|
||||||
|
innerStream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void DoObjectPost(OSDMap args, IOSHttpResponse httpResponse)
|
||||||
|
{
|
||||||
// retrieve the input arguments
|
// retrieve the input arguments
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
UUID uuid = UUID.Zero;
|
UUID uuid = UUID.Zero;
|
||||||
|
@ -169,8 +169,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.Message);
|
m_log.InfoFormat("[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.Message);
|
||||||
responsedata["int_response_code"] = HttpStatusCode.BadRequest;
|
httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
responsedata["str_response_string"] = "Bad request";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +204,11 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace);
|
m_log.DebugFormat("[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace);
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
responsedata["int_response_code"] = HttpStatusCode.OK;
|
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||||
responsedata["str_response_string"] = result.ToString();
|
httpResponse.RawBuffer = Util.UTF8.GetBytes(result.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// subclasses can override this
|
// subclasses can override this
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace OpenSim.Server.Handlers.Simulation
|
||||||
// are pure binary and shoehorning that into a string with UTF-8
|
// are pure binary and shoehorning that into a string with UTF-8
|
||||||
// encoding breaks it
|
// encoding breaks it
|
||||||
server.AddSimpleStreamHandler(new AgentSimpleHandler(m_LocalSimulationService), true);
|
server.AddSimpleStreamHandler(new AgentSimpleHandler(m_LocalSimulationService), true);
|
||||||
server.AddHTTPHandler("/object/", new ObjectHandler(m_LocalSimulationService).Handler);
|
server.AddSimpleStreamHandler(new ObjectSimpleHandler(m_LocalSimulationService), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue