move /estate handler
parent
c07f4f3c41
commit
b68748507d
|
@ -95,7 +95,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
|||
|
||||
// Instantiate the request handler
|
||||
IHttpServer server = MainServer.GetHttpServer(port);
|
||||
server.AddStreamHandler(new EstateRequestHandler(this, token));
|
||||
server.AddSimpleStreamHandler(new EstateSimpleRequestHandler(this, token));
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
|
@ -42,7 +43,7 @@ using log4net;
|
|||
|
||||
namespace OpenSim.Region.CoreModules.World.Estate
|
||||
{
|
||||
public class EstateRequestHandler : BaseStreamHandler
|
||||
public class EstateSimpleRequestHandler :SimpleStreamHandler
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -50,62 +51,83 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
|||
protected Object m_RequestLock = new Object();
|
||||
private string token;
|
||||
|
||||
public EstateRequestHandler(EstateModule fmodule, string _token)
|
||||
: base("POST", "/estate")
|
||||
public EstateSimpleRequestHandler(EstateModule fmodule, string _token) : base("/estate")
|
||||
{
|
||||
m_EstateModule = fmodule;
|
||||
token = _token;
|
||||
}
|
||||
|
||||
protected override byte[] ProcessRequest(string path, Stream requestData,
|
||||
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
string body;
|
||||
using(StreamReader sr = new StreamReader(requestData))
|
||||
body = sr.ReadToEnd();
|
||||
httpResponse.KeepAlive = false;
|
||||
if (httpRequest.HttpMethod != "POST")
|
||||
{
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
body = body.Trim();
|
||||
httpResponse.StatusCode = (int)HttpStatusCode.OK;
|
||||
|
||||
// m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
|
||||
|
||||
try
|
||||
{
|
||||
string body;
|
||||
using (StreamReader sr = new StreamReader(httpRequest.InputStream))
|
||||
body = sr.ReadToEnd();
|
||||
|
||||
body = body.Trim();
|
||||
lock (m_RequestLock)
|
||||
{
|
||||
Dictionary<string, object> request =
|
||||
ServerUtils.ParseQueryString(body);
|
||||
Dictionary<string, object> request = ServerUtils.ParseQueryString(body);
|
||||
|
||||
bool fail = true;
|
||||
while(true)
|
||||
{
|
||||
if (!request.ContainsKey("METHOD"))
|
||||
return FailureResult();
|
||||
break;
|
||||
|
||||
if (!request.ContainsKey("TOKEN"))
|
||||
return FailureResult();
|
||||
break;
|
||||
|
||||
string reqToken = request["TOKEN"].ToString();
|
||||
request.Remove("TOKEN");
|
||||
|
||||
if(token != reqToken)
|
||||
return FailureResult();
|
||||
break;
|
||||
|
||||
fail = false;
|
||||
break;
|
||||
}
|
||||
if(fail)
|
||||
{
|
||||
httpResponse.RawBuffer = FailureResult();
|
||||
return;
|
||||
}
|
||||
|
||||
string method = request["METHOD"].ToString();
|
||||
request.Remove("METHOD");
|
||||
request.Remove("TOKEN");
|
||||
|
||||
try
|
||||
{
|
||||
m_EstateModule.InInfoUpdate = false;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "update_covenant":
|
||||
return UpdateCovenant(request);
|
||||
httpResponse.RawBuffer = UpdateCovenant(request);
|
||||
return;
|
||||
case "update_estate":
|
||||
return UpdateEstate(request);
|
||||
httpResponse.RawBuffer = UpdateEstate(request);
|
||||
return;
|
||||
case "estate_message":
|
||||
return EstateMessage(request);
|
||||
httpResponse.RawBuffer = EstateMessage(request);
|
||||
return;
|
||||
case "teleport_home_one_user":
|
||||
return TeleportHomeOneUser(request);
|
||||
httpResponse.RawBuffer = TeleportHomeOneUser(request);
|
||||
return;
|
||||
case "teleport_home_all_users":
|
||||
return TeleportHomeAllUsers(request);
|
||||
httpResponse.RawBuffer = TeleportHomeAllUsers(request);
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
@ -119,7 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
|||
m_log.Debug("[XESTATE]: Exception {0}" + e.ToString());
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
httpResponse.RawBuffer = FailureResult();
|
||||
}
|
||||
|
||||
byte[] TeleportHomeAllUsers(Dictionary<string, object> request)
|
||||
|
|
Loading…
Reference in New Issue