From b6b0bc7b32ec5009eb482d51d0e9ff711e6ec022 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Nov 2011 16:15:52 +0000 Subject: Add "debug http" command for currently simple extra debug logging of non-event queue inbound http requests to a simulator --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 55 +++++++++++++++++----- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 3aed9a8..689a292 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -79,6 +79,11 @@ namespace OpenSim.Framework.Servers.HttpServer private PollServiceRequestManager m_PollServiceManager; + /// + /// Control the printing of certain debug messages. + /// + public int DebugLevel { get; set; } + public uint SSLPort { get { return m_sslport; } @@ -442,17 +447,20 @@ namespace OpenSim.Framework.Servers.HttpServer string path = request.RawUrl; string handlerKey = GetHandlerKey(request.HttpMethod, path); -// m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); + if (DebugLevel >= 1) + m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); if (TryGetStreamHandler(handlerKey, out requestHandler)) { - //m_log.Debug("[BASE HTTP SERVER]: Found Stream Handler"); + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found stream handler {0} for request to {1}", handlerKey, path); + // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. byte[] buffer = null; response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. - if (requestHandler is IStreamedRequestHandler) { IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; @@ -556,6 +564,7 @@ namespace OpenSim.Framework.Servers.HttpServer { m_log.Warn("[BASE HTTP SERVER]: XmlRpcRequest issue: " + e.Message); } + return; } @@ -566,7 +575,11 @@ namespace OpenSim.Framework.Servers.HttpServer if (strAccept.Contains("application/llsd+xml") || strAccept.Contains("application/llsd+json")) { - //m_log.Info("[Debug BASE HTTP SERVER]: Found an application/llsd+xml accept header"); + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found an application/llsd+xml accept header for request to {0}", + path); + HandleLLSDRequests(request, response); return; } @@ -577,15 +590,24 @@ namespace OpenSim.Framework.Servers.HttpServer { case null: case "text/html": -// m_log.DebugFormat( -// "[BASE HTTP SERVER]: Found a text/html content type for request {0}", request.RawUrl); + + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type for request to {1}", + request.ContentType, path); + HandleHTTPRequest(request, response); return; case "application/llsd+xml": case "application/xml+llsd": case "application/llsd+json": - //m_log.Info("[Debug BASE HTTP SERVER]: found a application/llsd+xml content type"); + + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found a {0} content type for request to {1}", + request.ContentType, path); + HandleLLSDRequests(request, response); return; @@ -602,7 +624,10 @@ namespace OpenSim.Framework.Servers.HttpServer //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler"); if (DoWeHaveALLSDHandler(request.RawUrl)) { - //m_log.Info("[Debug BASE HTTP SERVER]: Found LLSD Handler"); + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found an LLSD handler for request to {0}", path); + HandleLLSDRequests(request, response); return; } @@ -610,12 +635,18 @@ namespace OpenSim.Framework.Servers.HttpServer // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); if (DoWeHaveAHTTPHandler(request.RawUrl)) { -// m_log.DebugFormat("[BASE HTTP SERVER]: Found HTTP Handler for request {0}", request.RawUrl); + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Found an HTTP handler for request to {0}", path); + HandleHTTPRequest(request, response); return; } - //m_log.Info("[Debug BASE HTTP SERVER]: Generic XMLRPC"); + if (DebugLevel >= 2) + m_log.DebugFormat( + "[BASE HTTP SERVER]: Treating request to {0} as a generic XMLRPC request", path); + // generic login request. HandleXmlRpcRequests(request, response); @@ -978,7 +1009,6 @@ namespace OpenSim.Framework.Servers.HttpServer if (llsdRequest != null)// && m_defaultLlsdHandler != null) { - LLSDMethod llsdhandler = null; if (TryGetLLSDHandler(request.RawUrl, out llsdhandler) && !LegacyLLSDLoginLibOMV) @@ -1002,13 +1032,14 @@ namespace OpenSim.Framework.Servers.HttpServer llsdResponse = GenerateNoLLSDHandlerResponse(); } } - } else { llsdResponse = GenerateNoLLSDHandlerResponse(); } + byte[] buffer = new byte[0]; + if (llsdResponse.ToString() == "shutdown404!") { response.ContentType = "text/plain"; -- cgit v1.1 From 679a5f6c0b3c531e66311869646b972eb7cef834 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Nov 2011 17:26:45 +0000 Subject: With "debug http 1", show the path with the query string instead of just the path. Also simplifies debug levels to just 0 and 1 --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 689a292..7bd1836 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -447,14 +447,12 @@ namespace OpenSim.Framework.Servers.HttpServer string path = request.RawUrl; string handlerKey = GetHandlerKey(request.HttpMethod, path); - if (DebugLevel >= 1) - m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path); - if (TryGetStreamHandler(handlerKey, out requestHandler)) { - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found stream handler {0} for request to {1}", handlerKey, path); + "[BASE HTTP SERVER]: Found stream handler for {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler. byte[] buffer = null; @@ -488,7 +486,6 @@ namespace OpenSim.Framework.Servers.HttpServer string[] querystringkeys = request.QueryString.AllKeys; string[] rHeaders = request.Headers.AllKeys; - foreach (string queryname in querystringkeys) { keysvals.Add(queryname, request.QueryString[queryname]); @@ -575,10 +572,10 @@ namespace OpenSim.Framework.Servers.HttpServer if (strAccept.Contains("application/llsd+xml") || strAccept.Contains("application/llsd+json")) { - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found an application/llsd+xml accept header for request to {0}", - path); + "[BASE HTTP SERVER]: Found application/llsd+xml accept header handler for {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); HandleLLSDRequests(request, response); return; @@ -591,10 +588,10 @@ namespace OpenSim.Framework.Servers.HttpServer case null: case "text/html": - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type for request to {1}", - request.ContentType, path); + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); HandleHTTPRequest(request, response); return; @@ -603,10 +600,10 @@ namespace OpenSim.Framework.Servers.HttpServer case "application/xml+llsd": case "application/llsd+json": - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found a {0} content type for request to {1}", - request.ContentType, path); + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); HandleLLSDRequests(request, response); return; @@ -624,9 +621,10 @@ namespace OpenSim.Framework.Servers.HttpServer //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler"); if (DoWeHaveALLSDHandler(request.RawUrl)) { - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found an LLSD handler for request to {0}", path); + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); HandleLLSDRequests(request, response); return; @@ -635,17 +633,19 @@ namespace OpenSim.Framework.Servers.HttpServer // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); if (DoWeHaveAHTTPHandler(request.RawUrl)) { - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Found an HTTP handler for request to {0}", path); + "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", + request.ContentType, request.HttpMethod, request.Url.PathAndQuery); HandleHTTPRequest(request, response); return; } - if (DebugLevel >= 2) + if (DebugLevel >= 1) m_log.DebugFormat( - "[BASE HTTP SERVER]: Treating request to {0} as a generic XMLRPC request", path); + "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); // generic login request. HandleXmlRpcRequests(request, response); -- cgit v1.1 From fa63054c4f5cf970922c2fef386b084272c5491c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Nov 2011 20:37:03 +0000 Subject: On "show caps", stop excluding the seed cap but do exclude it elsewhere --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers/HttpServer') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 7bd1836..6bffba5 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -903,7 +903,9 @@ namespace OpenSim.Framework.Servers.HttpServer byte[] buf = Encoding.UTF8.GetBytes("Not found"); response.KeepAlive = false; - m_log.ErrorFormat("[BASE HTTP SERVER]: Handler not found for http request {0}", request.RawUrl); + m_log.ErrorFormat( + "[BASE HTTP SERVER]: Handler not found for http request {0} {1}", + request.HttpMethod, request.Url.PathAndQuery); response.SendChunked = false; response.ContentLength64 = buf.Length; -- cgit v1.1