aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/BaseHttpServer.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-19 18:11:44 +0000
committerJustin Clarke Casey2009-03-19 18:11:44 +0000
commitbd2180d9af21dd54d4199a9381afa3e43e913823 (patch)
tree7f82f0dd30e24d8eaa4f8cbb2493cb2f3f1c637f /OpenSim/Framework/Servers/BaseHttpServer.cs
parent* Lock http handlers dictionary in other places as well to avoid race conditions (diff)
downloadopensim-SC_OLD-bd2180d9af21dd54d4199a9381afa3e43e913823.zip
opensim-SC_OLD-bd2180d9af21dd54d4199a9381afa3e43e913823.tar.gz
opensim-SC_OLD-bd2180d9af21dd54d4199a9381afa3e43e913823.tar.bz2
opensim-SC_OLD-bd2180d9af21dd54d4199a9381afa3e43e913823.tar.xz
* refactor: Create IHttpServer interface instead of accessing BaseHttpServer via CommunicationsManager directly
Diffstat (limited to 'OpenSim/Framework/Servers/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs55
1 files changed, 3 insertions, 52 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 1b34209..28fb9df 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -41,10 +41,11 @@ using Nwc.XmlRpc;
41using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
42using CoolHTTPListener = HttpServer.HttpListener; 42using CoolHTTPListener = HttpServer.HttpListener;
43using HttpListener=System.Net.HttpListener; 43using HttpListener=System.Net.HttpListener;
44using OpenSim.Framework.Servers.Interfaces;
44 45
45namespace OpenSim.Framework.Servers 46namespace OpenSim.Framework.Servers
46{ 47{
47 public class BaseHttpServer 48 public class BaseHttpServer : IHttpServer
48 { 49 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 51 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
@@ -148,11 +149,6 @@ namespace OpenSim.Framework.Servers
148 return true; 149 return true;
149 } 150 }
150 151
151 /// <summary>
152 /// Gets the XML RPC handler for given method name
153 /// </summary>
154 /// <param name="method">Name of the method</param>
155 /// <returns>Returns null if not found</returns>
156 public XmlRpcMethod GetXmlRPCHandler(string method) 152 public XmlRpcMethod GetXmlRPCHandler(string method)
157 { 153 {
158 lock (m_rpcHandlers) 154 lock (m_rpcHandlers)
@@ -168,32 +164,6 @@ namespace OpenSim.Framework.Servers
168 } 164 }
169 } 165 }
170 166
171 /// <summary>
172 /// Add a handler for an HTTP request
173 /// </summary>
174 ///
175 /// This handler can actually be invoked either as
176 ///
177 /// http://<hostname>:<port>/?method=<methodName>
178 ///
179 /// or
180 ///
181 /// http://<hostname>:<port><method>
182 ///
183 /// if the method name starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
184 /// server will register a handler that can be invoked with either
185 ///
186 /// http://localhost:9000/?method=/object/
187 ///
188 /// or
189 ///
190 /// http://localhost:9000/object/
191 ///
192 /// <param name="methodName"></param>
193 /// <param name="handler"></param>
194 /// <returns>
195 /// true if the handler was successfully registered, false if a handler with the same name already existed.
196 /// </returns>
197 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) 167 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
198 { 168 {
199 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); 169 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
@@ -229,12 +199,6 @@ namespace OpenSim.Framework.Servers
229 return false; 199 return false;
230 } 200 }
231 201
232 /// <summary>
233 /// Adds a LLSD handler, yay.
234 /// </summary>
235 /// <param name="path">/resource/ path</param>
236 /// <param name="handler">handle the LLSD response</param>
237 /// <returns></returns>
238 public bool AddLLSDHandler(string path, LLSDMethod handler) 202 public bool AddLLSDHandler(string path, LLSDMethod handler)
239 { 203 {
240 lock (m_llsdHandlers) 204 lock (m_llsdHandlers)
@@ -1313,7 +1277,6 @@ namespace OpenSim.Framework.Servers
1313 response.ContentLength64 = buffer.Length; 1277 response.ContentLength64 = buffer.Length;
1314 response.ContentEncoding = Encoding.UTF8; 1278 response.ContentEncoding = Encoding.UTF8;
1315 1279
1316
1317 try 1280 try
1318 { 1281 {
1319 response.OutputStream.Write(buffer, 0, buffer.Length); 1282 response.OutputStream.Write(buffer, 0, buffer.Length);
@@ -1334,8 +1297,7 @@ namespace OpenSim.Framework.Servers
1334 // This has to be here to prevent a Linux/Mono crash 1297 // This has to be here to prevent a Linux/Mono crash
1335 m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e); 1298 m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", e);
1336 } 1299 }
1337 } 1300 }
1338
1339 } 1301 }
1340 1302
1341 public void SendHTML404(OSHttpResponse response, string host) 1303 public void SendHTML404(OSHttpResponse response, string host)
@@ -1513,11 +1475,6 @@ namespace OpenSim.Framework.Servers
1513 lock (m_streamHandlers) m_streamHandlers.Remove(handlerKey); 1475 lock (m_streamHandlers) m_streamHandlers.Remove(handlerKey);
1514 } 1476 }
1515 1477
1516 /// <summary>
1517 /// Remove an HTTP handler
1518 /// </summary>
1519 /// <param name="httpMethod"></param>
1520 /// <param name="path"></param>
1521 public void RemoveHTTPHandler(string httpMethod, string path) 1478 public void RemoveHTTPHandler(string httpMethod, string path)
1522 { 1479 {
1523 lock (m_HTTPHandlers) 1480 lock (m_HTTPHandlers)
@@ -1532,12 +1489,6 @@ namespace OpenSim.Framework.Servers
1532 } 1489 }
1533 } 1490 }
1534 1491
1535 /// <summary>
1536 /// Remove the agent IF it is registered. Intercept the possible exception.
1537 /// </summary>
1538 /// <param name="agent"></param>
1539 /// <param name="handler"></param>
1540 /// <returns></returns>
1541 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) 1492 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
1542 { 1493 {
1543 try 1494 try