diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4f82a3b884..ee6d854bef 100755 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -829,19 +829,14 @@ namespace OpenSim /// /// Currently this is always OK if the simulator is still listening for connections on its HTTP service /// - 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, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - return Util.UTF8.GetBytes("OK"); - } - - public override string ContentType - { - get { return "text/plain"; } + httpResponse.RawBuffer = Util.UTF8.GetBytes("OK"); + httpResponse.StatusCode = (int)HttpStatusCode.OK; } } @@ -849,25 +844,27 @@ namespace OpenSim /// Handler to supply the current extended status of this sim /// Sends the statistical data in a json serialization /// - public class XSimStatusHandler : BaseStreamHandler + public class XSimStatusHandler : SimpleStreamHandler { OpenSimBase m_opensim; public XSimStatusHandler(OpenSimBase sim) - : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") + : base("/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus") { m_opensim = sim; } - protected override byte[] ProcessRequest(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); - } - - public override string ContentType - { - get { return "text/plain"; } + try + { + httpResponse.RawBuffer = Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); + httpResponse.StatusCode = (int)HttpStatusCode.OK; + } + 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 /// associated value for jsonp used with ajax/javascript /// - protected class UXSimStatusHandler : BaseStreamHandler + protected class UXSimStatusHandler : SimpleStreamHandler { OpenSimBase m_opensim; public UXSimStatusHandler(OpenSimBase sim) - : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") + : base("/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus") { m_opensim = sim; } - protected override byte[] ProcessRequest(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); - } - - public override string ContentType - { - get { return "text/plain"; } + try + { + httpResponse.RawBuffer = Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); + httpResponse.StatusCode = (int)HttpStatusCode.OK; + } + catch + { + httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError; + } } } /// /// handler to supply serving http://domainname:port/robots.txt /// - public class SimRobotsHandler : BaseStreamHandler + public class SimRobotsHandler : SimpleStreamHandler { - public SimRobotsHandler() : base("GET", "/robots.txt", "SimRobots.txt", "Simulator Robots.txt") {} - - protected override byte[] ProcessRequest(string path, Stream request, - IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + private readonly byte[] binmsg; + public SimRobotsHandler() : base("/robots.txt", "SimRobots.txt", "Simulator Robots.txt") { - string robots = "# go away\nUser-agent: *\nDisallow: /\n"; - return Util.UTF8.GetBytes(robots); + binmsg = Util.UTF8.GetBytes("# go away\nUser-agent: *\nDisallow: /\n"); } - 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; } }