From 1b0abf8f0cd417e2a37cffc96379274ad98183f2 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 21 Sep 2012 00:29:13 +0100 Subject: [PATCH] Comment out the long unused afaik HTTP agent handlers. As far as I know, this was only used by the IBM Rest modules, much of which has been commented out for a very long time now. Other similar code uses HTTP or stream handlers instead. So commenting this out to reduce code complexity and the need to make this facility consistent with the others where it may not be used anyway. If this facility is actually being used then please notify me or uncomment it if you are core. --- .../Rest/Inventory/RestHandler.cs | 30 ++-- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 14 +- .../Servers/HttpServer/BaseHttpServer.cs | 146 +++++++++--------- .../HttpServer/Interfaces/IHttpServer.cs | 22 +-- OpenSim/Framework/Servers/MainServer.cs | 6 +- 5 files changed, 112 insertions(+), 106 deletions(-) diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs index cb88695600..072bd6f010 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs @@ -312,14 +312,16 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // Now that everything is setup we can proceed to // add THIS agent to the HTTP server's handler list - if (!AddAgentHandler(Rest.Name,this)) - { - Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId); - foreach (IRest handler in handlers) - { - handler.Close(); - } - } + // FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will + // have to be handled through the AddHttpHandler interface. +// if (!AddAgentHandler(Rest.Name,this)) +// { +// Rest.Log.ErrorFormat("{0} Unable to activate handler interface", MsgId); +// foreach (IRest handler in handlers) +// { +// handler.Close(); +// } +// } } catch (Exception e) @@ -342,11 +344,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId); - try - { - RemoveAgentHandler(Rest.Name, this); - } - catch (KeyNotFoundException){} + // FIXME: If this code is ever to be re-enabled (most of it is disabled already) then this will + // have to be handled through the AddHttpHandler interface. +// try +// { +// RemoveAgentHandler(Rest.Name, this); +// } +// catch (KeyNotFoundException){} foreach (IRest handler in handlers) { diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index eb167502b0..a2425b5cf3 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -297,7 +297,9 @@ namespace OpenSim.ApplicationPlugins.Rest { if (!IsEnabled) return false; _agents.Add(agentName, handler); - return _httpd.AddAgentHandler(agentName, handler); +// return _httpd.AddAgentHandler(agentName, handler); + + return false; } /// @@ -316,7 +318,7 @@ namespace OpenSim.ApplicationPlugins.Rest if (_agents[agentName] == handler) { _agents.Remove(agentName); - return _httpd.RemoveAgentHandler(agentName, handler); +// return _httpd.RemoveAgentHandler(agentName, handler); } return false; } @@ -358,10 +360,10 @@ namespace OpenSim.ApplicationPlugins.Rest _httpd.RemoveStreamHandler(h.HttpMethod, h.Path); } _handlers = null; - foreach (KeyValuePair h in _agents) - { - _httpd.RemoveAgentHandler(h.Key, h.Value); - } +// foreach (KeyValuePair h in _agents) +// { +// _httpd.RemoveAgentHandler(h.Key, h.Value); +// } _agents = null; } diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 05c2d53ea7..8c29ad479f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -82,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected Dictionary m_llsdHandlers = new Dictionary(); protected Dictionary m_streamHandlers = new Dictionary(); protected Dictionary m_HTTPHandlers = new Dictionary(); - protected Dictionary m_agentHandlers = new Dictionary(); +// protected Dictionary m_agentHandlers = new Dictionary(); protected Dictionary m_pollHandlers = new Dictionary(); @@ -260,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer return new List(m_pollHandlers.Keys); } - // Note that the agent string is provided simply to differentiate - // the handlers - it is NOT required to be an actual agent header - // value. - public bool AddAgentHandler(string agent, IHttpAgentHandler handler) - { - lock (m_agentHandlers) - { - if (!m_agentHandlers.ContainsKey(agent)) - { - m_agentHandlers.Add(agent, handler); - return true; - } - } - - //must already have a handler for that path so return false - return false; - } - - public List GetAgentHandlerKeys() - { - lock (m_agentHandlers) - return new List(m_agentHandlers.Keys); - } +// // Note that the agent string is provided simply to differentiate +// // the handlers - it is NOT required to be an actual agent header +// // value. +// public bool AddAgentHandler(string agent, IHttpAgentHandler handler) +// { +// lock (m_agentHandlers) +// { +// if (!m_agentHandlers.ContainsKey(agent)) +// { +// m_agentHandlers.Add(agent, handler); +// return true; +// } +// } +// +// //must already have a handler for that path so return false +// return false; +// } +// +// public List GetAgentHandlerKeys() +// { +// lock (m_agentHandlers) +// return new List(m_agentHandlers.Keys); +// } public bool AddLLSDHandler(string path, LLSDMethod handler) { @@ -438,22 +438,22 @@ namespace OpenSim.Framework.Servers.HttpServer Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); - // This is the REST agent interface. We require an agent to properly identify - // itself. If the REST handler recognizes the prefix it will attempt to - // satisfy the request. If it is not recognizable, and no damage has occurred - // the request can be passed through to the other handlers. This is a low - // probability event; if a request is matched it is normally expected to be - // handled - IHttpAgentHandler agentHandler; - - if (TryGetAgentHandler(request, response, out agentHandler)) - { - if (HandleAgentRequest(agentHandler, request, response)) - { - requestEndTick = Environment.TickCount; - return; - } - } +// // This is the REST agent interface. We require an agent to properly identify +// // itself. If the REST handler recognizes the prefix it will attempt to +// // satisfy the request. If it is not recognizable, and no damage has occurred +// // the request can be passed through to the other handlers. This is a low +// // probability event; if a request is matched it is normally expected to be +// // handled +// IHttpAgentHandler agentHandler; +// +// if (TryGetAgentHandler(request, response, out agentHandler)) +// { +// if (HandleAgentRequest(agentHandler, request, response)) +// { +// requestEndTick = Environment.TickCount; +// return; +// } +// } //response.KeepAlive = true; response.SendChunked = false; @@ -830,24 +830,24 @@ namespace OpenSim.Framework.Servers.HttpServer } } - private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) - { - agentHandler = null; - - lock (m_agentHandlers) - { - foreach (IHttpAgentHandler handler in m_agentHandlers.Values) - { - if (handler.Match(request, response)) - { - agentHandler = handler; - return true; - } - } - } - - return false; - } +// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) +// { +// agentHandler = null; +// +// lock (m_agentHandlers) +// { +// foreach (IHttpAgentHandler handler in m_agentHandlers.Values) +// { +// if (handler.Match(request, response)) +// { +// agentHandler = handler; +// return true; +// } +// } +// } +// +// return false; +// } /// /// Try all the registered xmlrpc handlers when an xmlrpc request is received. @@ -1772,21 +1772,21 @@ namespace OpenSim.Framework.Servers.HttpServer m_pollHandlers.Remove(path); } - public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) - { - lock (m_agentHandlers) - { - IHttpAgentHandler foundHandler; - - if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) - { - m_agentHandlers.Remove(agent); - return true; - } - } - - return false; - } +// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) +// { +// lock (m_agentHandlers) +// { +// IHttpAgentHandler foundHandler; +// +// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) +// { +// m_agentHandlers.Remove(agent); +// return true; +// } +// } +// +// return false; +// } public void RemoveXmlRPCHandler(string method) { diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index db58f6f468..0bd3aae7d5 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer uint Port { get; } bool UseSSL { get; } - // Note that the agent string is provided simply to differentiate - // the handlers - it is NOT required to be an actual agent header - // value. - bool AddAgentHandler(string agent, IHttpAgentHandler handler); +// // Note that the agent string is provided simply to differentiate +// // the handlers - it is NOT required to be an actual agent header +// // value. +// bool AddAgentHandler(string agent, IHttpAgentHandler handler); /// /// Add a handler for an HTTP request. @@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); - /// - /// Remove the agent if it is registered. - /// - /// - /// - /// - bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); +// /// +// /// Remove the agent if it is registered. +// /// +// /// +// /// +// /// +// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); /// /// Remove an HTTP handler diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 72f9cce31b..4b61b18fea 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs @@ -231,9 +231,9 @@ namespace OpenSim.Framework.Servers foreach (String s in httpServer.GetHTTPHandlerKeys()) handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); - handlers.AppendFormat("* Agent:\n"); - foreach (String s in httpServer.GetAgentHandlerKeys()) - handlers.AppendFormat("\t{0}\n", s); +// handlers.AppendFormat("* Agent:\n"); +// foreach (String s in httpServer.GetAgentHandlerKeys()) +// handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("* LLSD:\n"); foreach (String s in httpServer.GetLLSDHandlerKeys())