aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs86
1 files changed, 49 insertions, 37 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 214f936..a6e00c2 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -42,6 +42,7 @@ using Nwc.XmlRpc;
42using OpenMetaverse.StructuredData; 42using OpenMetaverse.StructuredData;
43using CoolHTTPListener = HttpServer.HttpListener; 43using CoolHTTPListener = HttpServer.HttpListener;
44using HttpListener=System.Net.HttpListener; 44using HttpListener=System.Net.HttpListener;
45using LogPrio=HttpServer.LogPrio;
45 46
46namespace OpenSim.Framework.Servers.HttpServer 47namespace OpenSim.Framework.Servers.HttpServer
47{ 48{
@@ -202,16 +203,14 @@ namespace OpenSim.Framework.Servers.HttpServer
202 if (!m_pollHandlers.ContainsKey(methodName)) 203 if (!m_pollHandlers.ContainsKey(methodName))
203 { 204 {
204 m_pollHandlers.Add(methodName,args); 205 m_pollHandlers.Add(methodName,args);
205 pollHandlerResult = true; 206 pollHandlerResult = true;
206
207 } 207 }
208 } 208 }
209 209
210 if (pollHandlerResult) 210 if (pollHandlerResult)
211 return AddHTTPHandler(methodName, handler); 211 return AddHTTPHandler(methodName, handler);
212 212
213 return false; 213 return false;
214
215 } 214 }
216 215
217 // Note that the agent string is provided simply to differentiate 216 // Note that the agent string is provided simply to differentiate
@@ -296,7 +295,7 @@ namespace OpenSim.Framework.Servers.HttpServer
296 headervals[headername] = req.Headers[headername]; 295 headervals[headername] = req.Headers[headername];
297 } 296 }
298 297
299 keysvals.Add("headers",headervals); 298 keysvals.Add("headers", headervals);
300 keysvals.Add("querystringkeys", querystringkeys); 299 keysvals.Add("querystringkeys", querystringkeys);
301 300
302 psEvArgs.Request(psreq.RequestID, keysvals); 301 psEvArgs.Request(psreq.RequestID, keysvals);
@@ -311,7 +310,7 @@ namespace OpenSim.Framework.Servers.HttpServer
311 } 310 }
312 catch (Exception e) 311 catch (Exception e)
313 { 312 {
314 m_log.ErrorFormat("[BASE HTTP SERVER]: OnRequest() failed with {0} {1}", e.Message, e.StackTrace); 313 m_log.Error(string.Format("[BASE HTTP SERVER]: OnRequest() failed with "), e);
315 } 314 }
316 } 315 }
317 316
@@ -343,7 +342,7 @@ namespace OpenSim.Framework.Servers.HttpServer
343 // the request can be passed through to the other handlers. This is a low 342 // the request can be passed through to the other handlers. This is a low
344 // probability event; if a request is matched it is normally expected to be 343 // probability event; if a request is matched it is normally expected to be
345 // handled 344 // handled
346 //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); 345// m_log.Debug("[BASE HTTP SERVER]: Handling request to " + request.RawUrl);
347 346
348 IHttpAgentHandler agentHandler; 347 IHttpAgentHandler agentHandler;
349 348
@@ -498,7 +497,8 @@ namespace OpenSim.Framework.Servers.HttpServer
498 { 497 {
499 case null: 498 case null:
500 case "text/html": 499 case "text/html":
501 //m_log.Info("[Debug BASE HTTP SERVER]: found a text/html content type"); 500// m_log.DebugFormat(
501// "[BASE HTTP SERVER]: Found a text/html content type for request {0}", request.RawUrl);
502 HandleHTTPRequest(request, response); 502 HandleHTTPRequest(request, response);
503 return; 503 return;
504 504
@@ -526,10 +526,11 @@ namespace OpenSim.Framework.Servers.HttpServer
526 HandleLLSDRequests(request, response); 526 HandleLLSDRequests(request, response);
527 return; 527 return;
528 } 528 }
529 //m_log.Info("[Debug BASE HTTP SERVER]: Checking for HTTP Handler"); 529
530// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
530 if (DoWeHaveAHTTPHandler(request.RawUrl)) 531 if (DoWeHaveAHTTPHandler(request.RawUrl))
531 { 532 {
532 //m_log.Info("[Debug BASE HTTP SERVER]: found HTTP Handler"); 533// m_log.DebugFormat("[BASE HTTP SERVER]: Found HTTP Handler for request {0}", request.RawUrl);
533 HandleHTTPRequest(request, response); 534 HandleHTTPRequest(request, response);
534 return; 535 return;
535 } 536 }
@@ -625,7 +626,7 @@ namespace OpenSim.Framework.Servers.HttpServer
625 626
626 private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) 627 private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
627 { 628 {
628 //m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); 629// m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey);
629 630
630 string bestMatch = null; 631 string bestMatch = null;
631 632
@@ -945,7 +946,7 @@ namespace OpenSim.Framework.Servers.HttpServer
945 } 946 }
946 catch (IOException e) 947 catch (IOException e)
947 { 948 {
948 m_log.DebugFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e); 949 m_log.WarnFormat("[BASE HTTP SERVER]: LLSD IOException {0}.", e);
949 } 950 }
950 catch (SocketException e) 951 catch (SocketException e)
951 { 952 {
@@ -1220,7 +1221,11 @@ namespace OpenSim.Framework.Servers.HttpServer
1220 } 1221 }
1221 1222
1222 public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response) 1223 public void HandleHTTPRequest(OSHttpRequest request, OSHttpResponse response)
1223 { 1224 {
1225// m_log.DebugFormat(
1226// "[BASE HTTP SERVER]: HandleHTTPRequest for request to {0}, method {1}",
1227// request.RawUrl, request.HttpMethod);
1228
1224 switch (request.HttpMethod) 1229 switch (request.HttpMethod)
1225 { 1230 {
1226 case "OPTIONS": 1231 case "OPTIONS":
@@ -1235,6 +1240,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1235 1240
1236 private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response) 1241 private void HandleContentVerbs(OSHttpRequest request, OSHttpResponse response)
1237 { 1242 {
1243// m_log.DebugFormat("[BASE HTTP SERVER]: HandleContentVerbs for request to {0}", request.RawUrl);
1244
1238 // This is a test. There's a workable alternative.. as this way sucks. 1245 // This is a test. There's a workable alternative.. as this way sucks.
1239 // We'd like to put this into a text file parhaps that's easily editable. 1246 // We'd like to put this into a text file parhaps that's easily editable.
1240 // 1247 //
@@ -1275,13 +1282,15 @@ namespace OpenSim.Framework.Servers.HttpServer
1275 1282
1276 foreach (string queryname in querystringkeys) 1283 foreach (string queryname in querystringkeys)
1277 { 1284 {
1285// m_log.DebugFormat(
1286// "[BASE HTTP SERVER]: Got query paremeter {0}={1}", queryname, request.QueryString[queryname]);
1278 keysvals.Add(queryname, request.QueryString[queryname]); 1287 keysvals.Add(queryname, request.QueryString[queryname]);
1279 requestVars.Add(queryname, keysvals[queryname]); 1288 requestVars.Add(queryname, keysvals[queryname]);
1280 } 1289 }
1281 1290
1282 foreach (string headername in rHeaders) 1291 foreach (string headername in rHeaders)
1283 { 1292 {
1284 //m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]); 1293// m_log.Debug("[BASE HTTP SERVER]: " + headername + "=" + request.Headers[headername]);
1285 headervals[headername] = request.Headers[headername]; 1294 headervals[headername] = request.Headers[headername];
1286 } 1295 }
1287 1296
@@ -1290,15 +1299,16 @@ namespace OpenSim.Framework.Servers.HttpServer
1290 host = (string)headervals["Host"]; 1299 host = (string)headervals["Host"];
1291 } 1300 }
1292 1301
1293 keysvals.Add("headers",headervals); 1302 keysvals.Add("headers", headervals);
1294 keysvals.Add("querystringkeys", querystringkeys); 1303 keysvals.Add("querystringkeys", querystringkeys);
1295 keysvals.Add("requestvars", requestVars); 1304 keysvals.Add("requestvars", requestVars);
1305// keysvals.Add("form", request.Form);
1296 1306
1297 if (keysvals.Contains("method")) 1307 if (keysvals.Contains("method"))
1298 { 1308 {
1299 //m_log.Warn("[HTTP]: Contains Method"); 1309// m_log.Debug("[BASE HTTP SERVER]: Contains Method");
1300 string method = (string) keysvals["method"]; 1310 string method = (string) keysvals["method"];
1301 //m_log.Warn("[HTTP]: " + requestBody); 1311// m_log.Debug("[BASE HTTP SERVER]: " + requestBody);
1302 GenericHTTPMethod requestprocessor; 1312 GenericHTTPMethod requestprocessor;
1303 bool foundHandler = TryGetHTTPHandler(method, out requestprocessor); 1313 bool foundHandler = TryGetHTTPHandler(method, out requestprocessor);
1304 if (foundHandler) 1314 if (foundHandler)
@@ -1310,13 +1320,12 @@ namespace OpenSim.Framework.Servers.HttpServer
1310 } 1320 }
1311 else 1321 else
1312 { 1322 {
1313 //m_log.Warn("[HTTP]: Handler Not Found"); 1323// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found");
1314 SendHTML404(response, host); 1324 SendHTML404(response, host);
1315 } 1325 }
1316 } 1326 }
1317 else 1327 else
1318 { 1328 {
1319
1320 GenericHTTPMethod requestprocessor; 1329 GenericHTTPMethod requestprocessor;
1321 bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor); 1330 bool foundHandler = TryGetHTTPHandlerPathBased(request.RawUrl, out requestprocessor);
1322 if (foundHandler) 1331 if (foundHandler)
@@ -1328,7 +1337,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1328 } 1337 }
1329 else 1338 else
1330 { 1339 {
1331 //m_log.Warn("[HTTP]: Handler Not Found"); 1340// m_log.Warn("[BASE HTTP SERVER]: Handler Not Found2");
1332 SendHTML404(response, host); 1341 SendHTML404(response, host);
1333 } 1342 }
1334 } 1343 }
@@ -1376,8 +1385,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1376 { 1385 {
1377 if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) 1386 if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
1378 { 1387 {
1379 // You have to specifically register for '/' and to get it, you must specificaly request it 1388 // You have to specifically register for '/' and to get it, you must specifically request it
1380 //
1381 if (pattern == "/" && searchquery == "/" || pattern != "/") 1389 if (pattern == "/" && searchquery == "/" || pattern != "/")
1382 bestMatch = pattern; 1390 bestMatch = pattern;
1383 } 1391 }
@@ -1572,7 +1580,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1572 1580
1573 public void Start() 1581 public void Start()
1574 { 1582 {
1575 m_log.Info("[BASE HTTP SERVER]: Starting up HTTP Server");
1576 StartHTTP(); 1583 StartHTTP();
1577 } 1584 }
1578 1585
@@ -1580,7 +1587,6 @@ namespace OpenSim.Framework.Servers.HttpServer
1580 { 1587 {
1581 try 1588 try
1582 { 1589 {
1583 m_log.Debug("[BASE HTTP SERVER]: Spawned main thread OK");
1584 //m_httpListener = new HttpListener(); 1590 //m_httpListener = new HttpListener();
1585 NotSocketErrors = 0; 1591 NotSocketErrors = 0;
1586 if (!m_ssl) 1592 if (!m_ssl)
@@ -1816,30 +1822,36 @@ namespace OpenSim.Framework.Servers.HttpServer
1816 /// <summary> 1822 /// <summary>
1817 /// Relays HttpServer log messages to our own logging mechanism. 1823 /// Relays HttpServer log messages to our own logging mechanism.
1818 /// </summary> 1824 /// </summary>
1819 /// There is also a UseTraceLogs line in this file that can be uncommented for more detailed log information 1825 /// To use this you must uncomment the switch section
1826 ///
1827 /// You may also be able to get additional trace information from HttpServer if you uncomment the UseTraceLogs
1828 /// property in StartHttp() for the HttpListener
1820 public class HttpServerLogWriter : ILogWriter 1829 public class HttpServerLogWriter : ILogWriter
1821 { 1830 {
1822 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 1831 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
1823 1832
1824 public void Write(object source, LogPrio priority, string message) 1833 public void Write(object source, LogPrio priority, string message)
1825 { 1834 {
1826 /* 1835 /*
1827 switch (priority) 1836 switch (priority)
1828 { 1837 {
1829 case HttpServer.LogPrio.Debug: 1838 case LogPrio.Trace:
1830 m_log.DebugFormat("[{0}]: {1}", source.ToString(), message); 1839 m_log.DebugFormat("[{0}]: {1}", source, message);
1840 break;
1841 case LogPrio.Debug:
1842 m_log.DebugFormat("[{0}]: {1}", source, message);
1831 break; 1843 break;
1832 case HttpServer.LogPrio.Error: 1844 case LogPrio.Error:
1833 m_log.ErrorFormat("[{0}]: {1}", source.ToString(), message); 1845 m_log.ErrorFormat("[{0}]: {1}", source, message);
1834 break; 1846 break;
1835 case HttpServer.LogPrio.Info: 1847 case LogPrio.Info:
1836 m_log.InfoFormat("[{0}]: {1}", source.ToString(), message); 1848 m_log.InfoFormat("[{0}]: {1}", source, message);
1837 break; 1849 break;
1838 case HttpServer.LogPrio.Warning: 1850 case LogPrio.Warning:
1839 m_log.WarnFormat("[{0}]: {1}", source.ToString(), message); 1851 m_log.WarnFormat("[{0}]: {1}", source, message);
1840 break; 1852 break;
1841 case HttpServer.LogPrio.Fatal: 1853 case LogPrio.Fatal:
1842 m_log.ErrorFormat("[{0}]: FATAL! - {1}", source.ToString(), message); 1854 m_log.ErrorFormat("[{0}]: FATAL! - {1}", source, message);
1843 break; 1855 break;
1844 default: 1856 default:
1845 break; 1857 break;
@@ -1849,4 +1861,4 @@ namespace OpenSim.Framework.Servers.HttpServer
1849 return; 1861 return;
1850 } 1862 }
1851 } 1863 }
1852} 1864} \ No newline at end of file