move some region base handlers to simpleStreamHandler

master
UbitUmarov 2020-04-25 15:31:30 +01:00
parent 80de74e127
commit ee77a6d80b
1 changed files with 37 additions and 39 deletions

View File

@ -829,19 +829,14 @@ namespace OpenSim
/// <remarks> /// <remarks>
/// Currently this is always OK if the simulator is still listening for connections on its HTTP service /// Currently this is always OK if the simulator is still listening for connections on its HTTP service
/// </remarks> /// </remarks>
public class SimStatusHandler : BaseStreamHandler public class SimStatusHandler : SimpleStreamHandler
{ {
public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {} public SimStatusHandler() : base("/simstatus", "SimStatus", "Simulator Status") {}
protected override byte[] ProcessRequest(string path, Stream request, protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes("OK"); httpResponse.RawBuffer = Util.UTF8.GetBytes("OK");
} httpResponse.StatusCode = (int)HttpStatusCode.OK;
public override string ContentType
{
get { return "text/plain"; }
} }
} }
@ -849,25 +844,27 @@ namespace OpenSim
/// Handler to supply the current extended status of this sim /// Handler to supply the current extended status of this sim
/// Sends the statistical data in a json serialization /// Sends the statistical data in a json serialization
/// </summary> /// </summary>
public class XSimStatusHandler : BaseStreamHandler public class XSimStatusHandler : SimpleStreamHandler
{ {
OpenSimBase m_opensim; OpenSimBase m_opensim;
public XSimStatusHandler(OpenSimBase sim) public XSimStatusHandler(OpenSimBase sim)
: base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") : base("/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
{ {
m_opensim = sim; m_opensim = sim;
} }
protected override byte[] ProcessRequest(string path, Stream request, protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); try
} {
httpResponse.RawBuffer = Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
public override string ContentType httpResponse.StatusCode = (int)HttpStatusCode.OK;
{ }
get { return "text/plain"; } catch
{
httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError;
}
} }
} }
@ -877,45 +874,46 @@ namespace OpenSim
/// If the request contains a key, "callback" the response will be wrappend in the /// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript /// associated value for jsonp used with ajax/javascript
/// </summary> /// </summary>
protected class UXSimStatusHandler : BaseStreamHandler protected class UXSimStatusHandler : SimpleStreamHandler
{ {
OpenSimBase m_opensim; OpenSimBase m_opensim;
public UXSimStatusHandler(OpenSimBase sim) public UXSimStatusHandler(OpenSimBase sim)
: base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") : base("/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
{ {
m_opensim = sim; m_opensim = sim;
} }
protected override byte[] ProcessRequest(string path, Stream request, protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); try
} {
httpResponse.RawBuffer = Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
public override string ContentType httpResponse.StatusCode = (int)HttpStatusCode.OK;
{ }
get { return "text/plain"; } catch
{
httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError;
}
} }
} }
/// <summary> /// <summary>
/// handler to supply serving http://domainname:port/robots.txt /// handler to supply serving http://domainname:port/robots.txt
/// </summary> /// </summary>
public class SimRobotsHandler : BaseStreamHandler public class SimRobotsHandler : SimpleStreamHandler
{ {
public SimRobotsHandler() : base("GET", "/robots.txt", "SimRobots.txt", "Simulator Robots.txt") {} private readonly byte[] binmsg;
public SimRobotsHandler() : base("/robots.txt", "SimRobots.txt", "Simulator Robots.txt")
protected override byte[] ProcessRequest(string path, Stream request,
IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
string robots = "# go away\nUser-agent: *\nDisallow: /\n"; binmsg = Util.UTF8.GetBytes("# go away\nUser-agent: *\nDisallow: /\n");
return Util.UTF8.GetBytes(robots);
} }
public override string ContentType protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{ {
get { return "text/plain"; } httpResponse.RawBuffer = binmsg;
httpResponse.StatusCode = (int)HttpStatusCode.OK;
return;
} }
} }