diff -r 027aca7ae47b OpenSim/Framework/Servers/BaseHttpServer.cs --- a/OpenSim/Framework/Servers/BaseHttpServer.cs Thu May 15 13:11:36 2008 -0400 +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs Fri May 16 11:35:32 2008 -0400 @@ -49,8 +49,9 @@ namespace OpenSim.Framework.Servers protected HttpListener m_httpListener; protected Dictionary m_rpcHandlers = new Dictionary(); protected LLSDMethod m_llsdHandler = null; - protected Dictionary m_streamHandlers = new Dictionary(); - protected Dictionary m_HTTPHandlers = new Dictionary(); + protected Dictionary m_streamHandlers = new Dictionary(); + protected Dictionary m_HTTPHandlers = new Dictionary(); + protected Dictionary m_agentHandlers = new Dictionary(); protected uint m_port; protected bool m_ssl = false; @@ -119,6 +120,18 @@ namespace OpenSim.Framework.Servers return false; } + public bool AddAgentHandler(string agent, IUserAgentHandler handler) + { + 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 bool SetLLSDHandler(LLSDMethod handler) { m_llsdHandler = handler; @@ -136,88 +149,128 @@ namespace OpenSim.Framework.Servers { HttpListenerContext context = (HttpListenerContext) stateinfo; - HttpListenerRequest request = context.Request; - HttpListenerResponse response = context.Response; + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; - response.KeepAlive = false; - response.SendChunked = false; - - string path = request.RawUrl; - string handlerKey = GetHandlerKey(request.HttpMethod, path); - - //m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); - - IRequestHandler requestHandler; - - if (TryGetStreamHandler(handlerKey, out requestHandler)) + for(int i=0;i + /// A specific agent handler was provided. Such a handler is expecetd to have an + /// intimate, and highly specific relationship with the client. Consequently, + /// nothing is done here. + /// + /// + /// + /// + + private void HandleAgentRequest(IUserAgentHandler handler, HttpListenerRequest request, HttpListenerResponse response) + { + + // In the case of REST, then handler is responsible for ALL aspects of + // the request/response handling. Nothing is done here, not even encoding. + + try + { + handler.Handle(request, response); + } + catch (Exception e) + { + m_log.Warn("[HTTP-AGENT]: Error - " + e.Message); + response.SendChunked = false; + response.KeepAlive = false; + response.StatusCode = 500; + response.OutputStream.Close(); + } + + } + /// /// Try all the registered xmlrpc handlers when an xmlrpc request is received. /// Sends back an XMLRPC unknown request response if no handler is registered for the requested method.