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