add a /index.php fake handler, for map. only does ?method=.. but can be extended)
							parent
							
								
									70d2878d0a
								
							
						
					
					
						commit
						dcc2f764f2
					
				|  | @ -105,6 +105,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
|         protected ConcurrentDictionary<string, PollServiceEventArgs> m_pollHandlers = | ||||
|             new ConcurrentDictionary<string, PollServiceEventArgs>(); | ||||
| 
 | ||||
|         protected ConcurrentDictionary<string, SimpleStreamMethod> m_indexPHPmethods = new ConcurrentDictionary<string, SimpleStreamMethod>(); | ||||
|         protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers = | ||||
|             new Dictionary<string, WebSocketRequestDelegate>(); | ||||
| 
 | ||||
|  | @ -535,6 +536,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         public void AddIndexPHPMethodHandler(string key, SimpleStreamMethod sh) | ||||
|         { | ||||
|             m_indexPHPmethods.TryAdd(key, sh); | ||||
|         } | ||||
| 
 | ||||
|         public void RemoveIndexPHPMethodHandler(string key) | ||||
|         { | ||||
|             m_indexPHPmethods.TryRemove(key, out SimpleStreamMethod sh); | ||||
|         } | ||||
| 
 | ||||
|         public SimpleStreamMethod TryGetIndexPHPMethodHandler(string key) | ||||
|         { | ||||
|             if(m_indexPHPmethods.TryGetValue(key, out SimpleStreamMethod sh)) | ||||
|                 return sh; | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         public void OnRequest(object source, RequestEventArgs args) | ||||
|         { | ||||
|             RequestNumber++; | ||||
|  |  | |||
|  | @ -149,5 +149,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
|         void RemoveJsonRPCHandler(string method); | ||||
| 
 | ||||
|         string GetHTTP404(); | ||||
|         void AddIndexPHPMethodHandler(string key, SimpleStreamMethod sh); | ||||
|         void RemoveIndexPHPMethodHandler(string key); | ||||
|         SimpleStreamMethod TryGetIndexPHPMethodHandler(string key); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -221,6 +221,7 @@ namespace OpenSim | |||
|             if (userStatsURI != String.Empty) | ||||
|                 MainServer.Instance.AddSimpleStreamHandler(new UXSimStatusHandler(this)); | ||||
|             MainServer.Instance.AddSimpleStreamHandler(new SimRobotsHandler()); | ||||
|             MainServer.Instance.AddSimpleStreamHandler(new IndexPHPHandler(MainServer.Instance)); | ||||
| 
 | ||||
|             if (managedStatsURI != String.Empty) | ||||
|             { | ||||
|  |  | |||
|  | @ -870,6 +870,56 @@ namespace OpenSim | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         public class IndexPHPHandler : SimpleStreamHandler | ||||
|         { | ||||
|             BaseHttpServer m_server; | ||||
| 
 | ||||
|             public IndexPHPHandler(BaseHttpServer server) | ||||
|                 : base("/index.php") | ||||
|             { | ||||
|                 m_server = server; | ||||
|             } | ||||
| 
 | ||||
|             protected override void ProcessRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | ||||
|             { | ||||
|                 httpResponse.KeepAlive = false; | ||||
|                 if(m_server == null || !m_server.HTTPDRunning) | ||||
|                 { | ||||
|                     httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 if (!httpRequest.QueryAsDictionary.TryGetValue("method", out string methods) || string.IsNullOrWhiteSpace(methods)) | ||||
|                 { | ||||
|                     httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 string[] splited = methods.Split(new char[]{','}); | ||||
|                 string method = splited[0]; | ||||
|                 if (string.IsNullOrWhiteSpace(method)) | ||||
|                 { | ||||
|                     httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 SimpleStreamMethod sh = m_server.TryGetIndexPHPMethodHandler(method); | ||||
|                 if (sh == null) | ||||
|                 { | ||||
|                     httpResponse.StatusCode = (int)HttpStatusCode.NotFound; | ||||
|                     return; | ||||
|                 } | ||||
|                 try | ||||
|                 { | ||||
|                     sh?.Invoke(httpRequest, httpResponse); | ||||
|                 } | ||||
|                 catch | ||||
|                 { | ||||
|                     httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Handler to supply the current extended status of this sim to a user configured URI | ||||
|         /// Sends the statistical data in a json serialization | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 UbitUmarov
						UbitUmarov