improve show http-handlers

master
UbitUmarov 2020-04-26 21:51:15 +01:00
parent b68748507d
commit 6050eff683
2 changed files with 27 additions and 59 deletions

View File

@ -380,6 +380,11 @@ namespace OpenSim.Framework.Servers.HttpServer
return ssh; return ssh;
} }
public List<string> GetIndexPHPHandlerKeys()
{
return new List<string>(m_indexPHPmethods.Keys);
}
private static string GetHandlerKey(string httpMethod, string path) private static string GetHandlerKey(string httpMethod, string path)
{ {
return httpMethod + ":" + path; return httpMethod + ":" + path;
@ -603,24 +608,8 @@ namespace OpenSim.Framework.Servers.HttpServer
Culture.SetCurrentCulture(); Culture.SetCurrentCulture();
// // This is the REST agent interface. We require an agent to properly identify
// // itself. If the REST handler recognizes the prefix it will attempt to
// // satisfy the request. If it is not recognizable, and no damage has occurred
// // the request can be passed through to the other handlers. This is a low
// // probability event; if a request is matched it is normally expected to be
// // handled
// IHttpAgentHandler agentHandler;
//
// if (TryGetAgentHandler(request, response, out agentHandler))
// {
// if (HandleAgentRequest(agentHandler, request, response))
// {
// requestEndTick = Environment.TickCount;
// return;
// }
// }
string path = request.UriPath; string path = request.UriPath;
if (path != "/" && (TryGetSimpleStreamHandler(path, out ISimpleStreamHandler hdr) || TryGetSimpleStreamVarPath(path, out hdr))) if (path != "/" && TryGetSimpleStreamHandler(path, out ISimpleStreamHandler hdr))
{ {
hdr.Handle(request, response); hdr.Handle(request, response);
if (request.InputStream != null && request.InputStream.CanRead) if (request.InputStream != null && request.InputStream.CanRead)
@ -675,11 +664,6 @@ namespace OpenSim.Framework.Servers.HttpServer
headervals[headername] = request.Headers[headername]; headervals[headername] = request.Headers[headername];
} }
// if (headervals.Contains("Host"))
// {
// host = (string)headervals["Host"];
// }
keysvals.Add("requestbody", requestBody); keysvals.Add("requestbody", requestBody);
keysvals.Add("headers",headervals); keysvals.Add("headers",headervals);
if (keysvals.Contains("method")) if (keysvals.Contains("method"))
@ -1059,11 +1043,9 @@ namespace OpenSim.Framework.Servers.HttpServer
private bool TryGetSimpleStreamHandler(string uripath, out ISimpleStreamHandler handler) private bool TryGetSimpleStreamHandler(string uripath, out ISimpleStreamHandler handler)
{ {
return m_simpleStreamHandlers.TryGetValue(uripath, out handler); if(m_simpleStreamHandlers.TryGetValue(uripath, out handler))
} return true;
private bool TryGetSimpleStreamVarPath(string uripath, out ISimpleStreamHandler handler)
{
handler = null; handler = null;
if(uripath.Length < 3) if(uripath.Length < 3)
return false; return false;
@ -1074,25 +1056,6 @@ namespace OpenSim.Framework.Servers.HttpServer
return m_simpleStreamVarPath.TryGetValue(uripath.Substring(0,indx), out handler); return m_simpleStreamVarPath.TryGetValue(uripath.Substring(0,indx), out handler);
} }
// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
// {
// agentHandler = null;
//
// lock (m_agentHandlers)
// {
// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
// {
// if (handler.Match(request, response))
// {
// agentHandler = handler;
// return true;
// }
// }
// }
//
// return false;
// }
/// <summary> /// <summary>
/// Try all the registered xmlrpc handlers when an xmlrpc request is received. /// Try all the registered xmlrpc handlers when an xmlrpc request is received.
/// Sends back an XMLRPC unknown request response if no handler is registered for the requested method. /// Sends back an XMLRPC unknown request response if no handler is registered for the requested method.
@ -1115,7 +1078,6 @@ namespace OpenSim.Framework.Servers.HttpServer
using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
requestBody = reader.ReadToEnd(); requestBody = reader.ReadToEnd();
} }
finally finally
{ {

View File

@ -241,28 +241,34 @@ namespace OpenSim.Framework.Servers
handlers.AppendFormat( handlers.AppendFormat(
"Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port);
handlers.AppendFormat("* XMLRPC:\n"); List<string> lst = httpServer.GetXmlRpcHandlerKeys();
foreach (String s in httpServer.GetXmlRpcHandlerKeys()) handlers.AppendFormat("* XMLRPC methods ({0}):\n",lst.Count);
foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("\t{0}\n", s);
handlers.AppendFormat("* HTTP:\n"); lst = httpServer.GetJsonRpcHandlerKeys();
foreach (String s in httpServer.GetHTTPHandlerKeys()) handlers.AppendFormat("* JSONRPC methods ({0}):\n", lst.Count);
foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("\t{0}\n", s);
handlers.AppendFormat("* HTTP (poll):\n"); lst = httpServer.GetIndexPHPHandlerKeys();
foreach (String s in httpServer.GetPollServiceHandlerKeys()) handlers.AppendFormat("* index.php methods ({0}):\n", lst.Count);
foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("\t{0}\n", s);
handlers.AppendFormat("* JSONRPC:\n"); lst = httpServer.GetHTTPHandlerKeys();
foreach (String s in httpServer.GetJsonRpcHandlerKeys()) handlers.AppendFormat("* HTTP ({0}):\n", lst.Count);
foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("\t{0}\n", s);
// handlers.AppendFormat("* Agent:\n"); lst = httpServer.GetPollServiceHandlerKeys();
// foreach (String s in httpServer.GetAgentHandlerKeys()) handlers.AppendFormat("* HTTP poll ({0}):\n", lst.Count);
// handlers.AppendFormat("\t{0}\n", s); foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s);
handlers.AppendFormat("* LLSD:\n"); lst = httpServer.GetLLSDHandlerKeys();
foreach (String s in httpServer.GetLLSDHandlerKeys()) handlers.AppendFormat("* LLSD ({0}):\n", lst.Count);
foreach (String s in lst)
handlers.AppendFormat("\t{0}\n", s); handlers.AppendFormat("\t{0}\n", s);
List<string> shdrs = httpServer.GetStreamHandlerKeys(); List<string> shdrs = httpServer.GetStreamHandlerKeys();