From eb0c36940943390504629576c0824efcde75bffb Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 19 Mar 2009 16:41:23 +0000
Subject: * Add documentation to BaseHttpServer.AddHTTPHandler()
---
OpenSim/Framework/Servers/BaseHttpServer.cs | 54 ++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 5bd0fa5..18b53b1 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -168,13 +168,41 @@ namespace OpenSim.Framework.Servers
}
}
- public bool AddHTTPHandler(string method, GenericHTTPMethod handler)
+ ///
+ /// Add a handler for an HTTP request
+ ///
+ ///
+ /// This handler can actually be invoked either as
+ ///
+ /// http://:/?method=
+ ///
+ /// or
+ ///
+ /// http://:
+ ///
+ /// 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/
+ ///
+ ///
+ ///
+ ///
+ /// true if the handler was successfully registered, false if a handler with the same name already existed.
+ ///
+ public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
{
+ //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
+
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;
}
}
@@ -517,6 +545,8 @@ namespace OpenSim.Framework.Servers
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
{
+ //m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey);
+
string bestMatch = null;
foreach (string pattern in m_HTTPHandlers.Keys)
@@ -878,7 +908,6 @@ namespace OpenSim.Framework.Servers
/// true if we have one, false if not
private bool DoWeHaveAHTTPHandler(string path)
{
-
string[] pathbase = path.Split('/');
string searchquery = "/";
@@ -894,14 +923,13 @@ namespace OpenSim.Framework.Servers
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)
{
-
if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
{
-
bestMatch = pattern;
-
}
}
@@ -911,12 +939,10 @@ namespace OpenSim.Framework.Servers
if (String.IsNullOrEmpty(bestMatch))
{
-
return false;
}
else
{
-
return true;
}
}
@@ -1024,7 +1050,8 @@ namespace OpenSim.Framework.Servers
catch (SocketException f)
{
// 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)
@@ -1184,6 +1211,9 @@ namespace OpenSim.Framework.Servers
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)
{
if (searchquery.ToLower().StartsWith(pattern.ToLower()))
@@ -1196,9 +1226,7 @@ namespace OpenSim.Framework.Servers
bestMatch = pattern;
}
}
- }
-
-
+ }
if (String.IsNullOrEmpty(bestMatch))
{
--
cgit v1.1