* Updated C# WebServer to the latest available source download (r19869) and applied a few mods from the old version (now up on opensim-libs (VS 3.5 project).

* Made various changes to BaseHttpServer to accommodate the new interfaces.
* This version has been significantly re-architected and may fail in unusual and insidious ways.  
* Please pay attention to any errors you get and post a Mantis if you can reproduce an issue with the HTTPServer.  I'm including the pdb and having the http server compiled in debug for a few weeks so that when an error occurs, it'll print the pertenant data.
* Once again, this is the full C# WebServer, not the lite branch that is included in LibOMV (we need SSL!)
This commit is contained in:
Teravus Ovares
2009-07-21 06:47:29 +00:00
parent 156c393a44
commit c243ae43f2
8 changed files with 3957 additions and 5559 deletions

View File

@@ -226,6 +226,15 @@ namespace OpenSim.Framework.Servers.HttpServer
return true;
}
private void OnRequest(object source, RequestEventArgs args)
{
IHttpClientContext context = (IHttpClientContext)source;
IHttpRequest request = args.Request;
OnHandleRequestIOThread(context,request);
}
public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
{
OSHttpRequest req = new OSHttpRequest(context, request);
@@ -1406,7 +1415,7 @@ namespace OpenSim.Framework.Servers.HttpServer
{
//m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
//m_httpListener.Prefixes.Add("http://10.1.1.5:" + m_port + "/");
m_httpListener2 = new CoolHTTPListener(m_listenIPAddress, (int)m_port);
m_httpListener2 = CoolHTTPListener.Create(m_listenIPAddress, (int)m_port);
m_httpListener2.ExceptionThrown += httpServerException;
m_httpListener2.LogWriter = httpserverlog;
@@ -1414,7 +1423,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// if you want more detailed trace information from the HttpServer
//m_httpListener2.UseTraceLogs = true;
m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor;
//m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor;
}
else
{
@@ -1422,7 +1431,7 @@ namespace OpenSim.Framework.Servers.HttpServer
//m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
}
m_httpListener2.RequestHandler += OnHandleRequestIOThread;
m_httpListener2.RequestReceived += OnRequest;
//m_httpListener.Start();
m_httpListener2.Start(64);
HTTPDRunning = true;
@@ -1474,10 +1483,10 @@ namespace OpenSim.Framework.Servers.HttpServer
{
HTTPDRunning = false;
m_httpListener2.ExceptionThrown -= httpServerException;
m_httpListener2.DisconnectHandler = null;
//m_httpListener2.DisconnectHandler = null;
m_httpListener2.LogWriter = null;
m_httpListener2.RequestHandler -= OnHandleRequestIOThread;
m_httpListener2.RequestReceived -= OnRequest;
m_httpListener2.Stop();
}

View File

@@ -46,6 +46,10 @@ namespace OpenSim.Framework.Servers.Tests
public class TestHttpClientContext: IHttpClientContext
{
private bool _secured;
public bool IsSecured
{
get { return _secured; }
}
public bool Secured
{
get { return _secured; }
@@ -62,10 +66,19 @@ namespace OpenSim.Framework.Servers.Tests
public void Respond(string body) {}
public void Send(byte[] buffer) {}
public void Send(byte[] buffer, int offset, int size) {}
public void Respond(string httpVersion, HttpStatusCode statusCode, string reason, string body, string contentType) {}
public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
/// <summary>
/// A request have been received in the context.
/// </summary>
public event EventHandler<RequestEventArgs> RequestReceived = delegate { };
}
public class TestHttpRequest: IHttpRequest
{
private string _uriPath;
public bool BodyIsComplete
{
get { return true; }
@@ -183,6 +196,24 @@ namespace OpenSim.Framework.Servers.Tests
return clone;
}
public IHttpResponse CreateResponse(IHttpClientContext context)
{
return new HttpResponse(context, this);
}
/// <summary>
/// Path and query (will be merged with the host header) and put in Uri
/// </summary>
/// <see cref="Uri"/>
public string UriPath
{
get { return _uriPath; }
set
{
_uriPath = value;
}
}
}
public class TestHttpResponse: IHttpResponse

View File

@@ -112,15 +112,15 @@ TD.align_top { vertical-align: top; }
ajaxUpdaterDivs[0] = "activeconnections";
ajaxUpdaterSeconds[0] = 10;
ajaxUpdaterReportFragments[0] = "activeconnectionsajax.ajax";
ajaxUpdaterReportFragments[0] = "activeconnectionsajax.html";
ajaxUpdaterDivs[1] = "activesimstats";
ajaxUpdaterSeconds[1] = 20;
ajaxUpdaterReportFragments[1] = "simstatsajax.ajax";
ajaxUpdaterReportFragments[1] = "simstatsajax.html";
ajaxUpdaterDivs[2] = "activelog";
ajaxUpdaterSeconds[2] = 5;
ajaxUpdaterReportFragments[2] = "activelogajax.ajax";
ajaxUpdaterReportFragments[2] = "activelogajax.html";
HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);

View File

@@ -110,9 +110,9 @@ namespace OpenSim.Region.UserStatistics
reports.Add("", rep);
reports.Add("prototype.js", protodep);
reports.Add("updater.js", updatedep);
reports.Add("activeconnectionsajax.ajax", ajConnections);
reports.Add("simstatsajax.ajax", ajSimStats);
reports.Add("activelogajax.ajax", ajLogLines);
reports.Add("activeconnectionsajax.html", ajConnections);
reports.Add("simstatsajax.html", ajSimStats);
reports.Add("activelogajax.html", ajLogLines);
reports.Add("clients.report", clientReport);
reports.Add("sessions.report", sessionsReport);