* Add documentation to BaseHttpServer.AddHTTPHandler()
parent
0867302e09
commit
eb0c369409
|
@ -168,13 +168,41 @@ namespace OpenSim.Framework.Servers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddHTTPHandler(string method, GenericHTTPMethod handler)
|
/// <summary>
|
||||||
|
/// Add a handler for an HTTP request
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// This handler can actually be invoked either as
|
||||||
|
///
|
||||||
|
/// http://<hostname>:<port>/?method=<methodName>
|
||||||
|
///
|
||||||
|
/// or
|
||||||
|
///
|
||||||
|
/// http://<hostname>:<port><method>
|
||||||
|
///
|
||||||
|
/// if the method starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
|
||||||
|
/// server will register a handler that can be invoked with either
|
||||||
|
///
|
||||||
|
/// http://localhost:9000/?method=/object/
|
||||||
|
///
|
||||||
|
/// or
|
||||||
|
///
|
||||||
|
/// http://localhost:9000/object/
|
||||||
|
///
|
||||||
|
/// <param name="methodName"></param>
|
||||||
|
/// <param name="handler"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// true if the handler was successfully registered, false if a handler with the same name already existed.
|
||||||
|
/// </returns>
|
||||||
|
public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
|
||||||
{
|
{
|
||||||
|
//m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
|
||||||
|
|
||||||
lock (m_HTTPHandlers)
|
lock (m_HTTPHandlers)
|
||||||
{
|
{
|
||||||
if (!m_HTTPHandlers.ContainsKey(method))
|
if (!m_HTTPHandlers.ContainsKey(methodName))
|
||||||
{
|
{
|
||||||
m_HTTPHandlers.Add(method, handler);
|
m_HTTPHandlers.Add(methodName, handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,6 +545,8 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
|
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
|
||||||
{
|
{
|
||||||
|
//m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey);
|
||||||
|
|
||||||
string bestMatch = null;
|
string bestMatch = null;
|
||||||
|
|
||||||
foreach (string pattern in m_HTTPHandlers.Keys)
|
foreach (string pattern in m_HTTPHandlers.Keys)
|
||||||
|
@ -878,7 +908,6 @@ namespace OpenSim.Framework.Servers
|
||||||
/// <returns>true if we have one, false if not</returns>
|
/// <returns>true if we have one, false if not</returns>
|
||||||
private bool DoWeHaveAHTTPHandler(string path)
|
private bool DoWeHaveAHTTPHandler(string path)
|
||||||
{
|
{
|
||||||
|
|
||||||
string[] pathbase = path.Split('/');
|
string[] pathbase = path.Split('/');
|
||||||
string searchquery = "/";
|
string searchquery = "/";
|
||||||
|
|
||||||
|
@ -894,14 +923,13 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
string bestMatch = null;
|
string bestMatch = null;
|
||||||
|
|
||||||
|
//m_log.DebugFormat("[BASE HTTP HANDLER]: Checking if we have an HTTP handler for {0}", searchquery);
|
||||||
|
|
||||||
foreach (string pattern in m_HTTPHandlers.Keys)
|
foreach (string pattern in m_HTTPHandlers.Keys)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
|
if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
|
||||||
{
|
{
|
||||||
|
|
||||||
bestMatch = pattern;
|
bestMatch = pattern;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,12 +939,10 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(bestMatch))
|
if (String.IsNullOrEmpty(bestMatch))
|
||||||
{
|
{
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1024,7 +1050,8 @@ namespace OpenSim.Framework.Servers
|
||||||
catch (SocketException f)
|
catch (SocketException f)
|
||||||
{
|
{
|
||||||
// This has to be here to prevent a Linux/Mono crash
|
// This has to be here to prevent a Linux/Mono crash
|
||||||
m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", f);
|
m_log.WarnFormat(
|
||||||
|
"[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception)
|
catch(Exception)
|
||||||
|
@ -1184,6 +1211,9 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
string bestMatch = null;
|
string bestMatch = null;
|
||||||
|
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery);
|
||||||
|
|
||||||
foreach (string pattern in m_HTTPHandlers.Keys)
|
foreach (string pattern in m_HTTPHandlers.Keys)
|
||||||
{
|
{
|
||||||
if (searchquery.ToLower().StartsWith(pattern.ToLower()))
|
if (searchquery.ToLower().StartsWith(pattern.ToLower()))
|
||||||
|
@ -1196,9 +1226,7 @@ namespace OpenSim.Framework.Servers
|
||||||
bestMatch = pattern;
|
bestMatch = pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(bestMatch))
|
if (String.IsNullOrEmpty(bestMatch))
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,21 +69,19 @@ namespace OpenSim.Region.UserStatistics
|
||||||
private string m_loglines = String.Empty;
|
private string m_loglines = String.Empty;
|
||||||
private volatile int lastHit = 12000;
|
private volatile int lastHit = 12000;
|
||||||
|
|
||||||
|
|
||||||
public virtual void Initialise(Scene scene, IConfigSource config)
|
public virtual void Initialise(Scene scene, IConfigSource config)
|
||||||
{
|
{
|
||||||
IConfig cnfg;
|
IConfig cnfg;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cnfg = config.Configs["WebStats"];
|
cnfg = config.Configs["WebStats"];
|
||||||
enabled = cnfg.GetBoolean("enabled", false);
|
enabled = cnfg.GetBoolean("enabled", false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -130,14 +128,12 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
|
scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
|
||||||
scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
|
scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.Add(scene);
|
m_scene.Add(scene);
|
||||||
m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID));
|
m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID));
|
||||||
scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket;
|
scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReceiveClassicSimStatsPacket(SimStats stats)
|
public void ReceiveClassicSimStatsPacket(SimStats stats)
|
||||||
|
@ -168,10 +164,10 @@ namespace OpenSim.Region.UserStatistics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException)
|
catch (KeyNotFoundException)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable HandleUnknownCAPSRequest(Hashtable request)
|
public Hashtable HandleUnknownCAPSRequest(Hashtable request)
|
||||||
{
|
{
|
||||||
//string regpath = request["uri"].ToString();
|
//string regpath = request["uri"].ToString();
|
||||||
|
@ -247,9 +243,7 @@ namespace OpenSim.Region.UserStatistics
|
||||||
|
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void CheckAndUpdateDatabase(SqliteConnection db)
|
public void CheckAndUpdateDatabase(SqliteConnection db)
|
||||||
{
|
{
|
||||||
lock (db)
|
lock (db)
|
||||||
|
|
Loading…
Reference in New Issue