28 using System.Collections;
29 using System.Collections.Generic;
30 using OpenSim.Framework.Servers;
31 using OpenSim.Framework.Servers.HttpServer;
33 namespace OpenSim.Framework.Capabilities
42 private Dictionary<string, IRequestHandler> m_capsHandlers =
new Dictionary<string, IRequestHandler>();
44 private string m_httpListenerHostName;
45 private uint m_httpListenerPort;
46 private bool m_useSSL =
false;
57 : this(httpListener,httpListenerHostname,httpListenerPort, false)
72 m_httpListener = httpListener;
73 m_httpListenerHostName = httpListenerHostname;
74 m_httpListenerPort = httpListenerPort;
76 if (httpListener != null && m_useSSL)
78 m_httpListenerHostName = httpListener.SSLCommonName;
79 m_httpListenerPort = httpListener.SSLPort;
92 m_httpListener.RemoveStreamHandler(
"POST", m_capsHandlers[capsName].Path);
93 m_httpListener.RemoveStreamHandler(
"PUT", m_capsHandlers[capsName].Path);
94 m_httpListener.RemoveStreamHandler(
"GET", m_capsHandlers[capsName].Path);
95 m_capsHandlers.Remove(capsName);
101 lock (m_capsHandlers)
102 return m_capsHandlers.ContainsKey(cap);
118 lock (m_capsHandlers)
119 return m_capsHandlers[idx];
124 lock (m_capsHandlers)
126 if (m_capsHandlers.ContainsKey(idx))
128 m_httpListener.RemoveStreamHandler(
"POST", m_capsHandlers[idx].Path);
129 m_capsHandlers.Remove(idx);
132 if (null == value)
return;
134 m_capsHandlers[idx] = value;
135 m_httpListener.AddStreamHandler(value);
148 lock (m_capsHandlers)
150 string[] __keys =
new string[m_capsHandlers.Keys.Count];
151 m_capsHandlers.Keys.CopyTo(__keys, 0);
164 Hashtable caps =
new Hashtable();
165 string protocol =
"http://";
168 protocol =
"https://";
170 string baseUrl = protocol + m_httpListenerHostName +
":" + m_httpListenerPort.ToString();
172 lock (m_capsHandlers)
174 foreach (
string capsName
in m_capsHandlers.Keys)
176 if (excludeSeed &&
"SEED" == capsName)
179 if (requestedCaps != null && !requestedCaps.Contains(capsName))
182 caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
197 lock (m_capsHandlers)
198 return new Dictionary<string, IRequestHandler>(m_capsHandlers);
Dictionary< string, IRequestHandler > GetCapsHandlers()
Returns a copy of the dictionary of all the HTTP cap handlers
CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https)
bool ContainsCap(string cap)
void Remove(string capsName)
Remove the cap handler for a capability.
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs.
CapsHandlers is a cap handler container but also takes care of adding and removing cap handlers to an...
Hashtable GetCapsDetails(bool excludeSeed, List< string > requestedCaps)
Return an LLSD-serializable Hashtable describing the capabilities and their handler details...
CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort)