Shuffle "debug http" levels so that 1 and 2 now cause different levels of warn to be logged if we receive invalid xml for xmlrpc.

0.7.4.1
Justin Clark-Casey (justincc) 2012-06-14 23:46:09 +01:00
parent f4b02f8e39
commit 9825861f4a
2 changed files with 32 additions and 12 deletions

View File

@ -82,6 +82,11 @@ namespace OpenSim.Framework.Servers.HttpServer
/// <summary> /// <summary>
/// Control the printing of certain debug messages. /// Control the printing of certain debug messages.
/// </summary> /// </summary>
/// <remarks>
/// If DebugLevel >= 1, then short warnings are logged when receiving bad input data.
/// If DebugLevel >= 2, then long warnings are logged when receiving bad input data.
/// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged.
/// </remarks>
public int DebugLevel { get; set; } public int DebugLevel { get; set; }
public uint SSLPort public uint SSLPort
@ -450,7 +455,7 @@ namespace OpenSim.Framework.Servers.HttpServer
if (TryGetStreamHandler(handlerKey, out requestHandler)) if (TryGetStreamHandler(handlerKey, out requestHandler))
{ {
if (DebugLevel >= 1) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}",
request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description);
@ -531,7 +536,7 @@ namespace OpenSim.Framework.Servers.HttpServer
case null: case null:
case "text/html": case "text/html":
if (DebugLevel >= 1) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery); request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@ -543,7 +548,7 @@ namespace OpenSim.Framework.Servers.HttpServer
case "application/xml+llsd": case "application/xml+llsd":
case "application/llsd+json": case "application/llsd+json":
if (DebugLevel >= 1) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery); request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@ -564,7 +569,7 @@ namespace OpenSim.Framework.Servers.HttpServer
//m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler"); //m_log.Info("[Debug BASE HTTP SERVER]: Checking for LLSD Handler");
if (DoWeHaveALLSDHandler(request.RawUrl)) if (DoWeHaveALLSDHandler(request.RawUrl))
{ {
if (DebugLevel >= 1) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery); request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@ -574,7 +579,7 @@ namespace OpenSim.Framework.Servers.HttpServer
// m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
else if (DoWeHaveAHTTPHandler(request.RawUrl)) else if (DoWeHaveAHTTPHandler(request.RawUrl))
{ {
if (DebugLevel >= 1) if (DebugLevel >= 3)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}",
request.ContentType, request.HttpMethod, request.Url.PathAndQuery); request.ContentType, request.HttpMethod, request.Url.PathAndQuery);
@ -583,8 +588,7 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
else else
{ {
if (DebugLevel >= 3)
if (DebugLevel >= 1)
m_log.DebugFormat( m_log.DebugFormat(
"[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}",
request.HttpMethod, request.Url.PathAndQuery); request.HttpMethod, request.Url.PathAndQuery);
@ -793,8 +797,23 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
} }
catch (XmlException) catch (XmlException e)
{ {
if (DebugLevel >= 1)
{
if (DebugLevel >= 2)
m_log.Warn(
string.Format(
"[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}. XML was '{1}'. Sending blank response. Exception ",
request.RemoteIPEndPoint, requestBody),
e);
else
{
m_log.WarnFormat(
"[BASE HTTP SERVER]: Got XMLRPC request with invalid XML from {0}, length {1}. Sending blank response.",
request.RemoteIPEndPoint, requestBody.Length);
}
}
} }
if (xmlRprcRequest != null) if (xmlRprcRequest != null)

View File

@ -250,10 +250,11 @@ namespace OpenSim
m_console.Commands.AddCommand("Comms", false, "debug http", m_console.Commands.AddCommand("Comms", false, "debug http",
"debug http <level>", "debug http <level>",
"Turn on inbound http request debugging for everything except the event queue (see debug eq).", "Turn on inbound non-poll http request debugging for everything except the event queue (see debug eq).",
"If level >= 2 then the handler used to service the request is logged.\n" "If level <= 0, then no extra logging is done.\n"
+ "If level >= 1 then incoming HTTP requests are logged.\n" + "If level >= 1, then short warnings are logged when receiving bad input data.\n"
+ "If level <= 0 then no extra http logging is done.\n", + "If level >= 2, then long warnings are logged when receiving bad input data.\n"
+ "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n",
Debug); Debug);
m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug); m_console.Commands.AddCommand("Comms", false, "debug teleport", "debug teleport", "Toggle teleport route debugging", Debug);