aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-03-19 16:41:23 +0000
committerJustin Clarke Casey2009-03-19 16:41:23 +0000
commiteb0c36940943390504629576c0824efcde75bffb (patch)
tree252df9e94efea082622ee686201968f5e65f991f
parentreformatting README (just noticed that that line was a bit on the long (diff)
downloadopensim-SC_OLD-eb0c36940943390504629576c0824efcde75bffb.zip
opensim-SC_OLD-eb0c36940943390504629576c0824efcde75bffb.tar.gz
opensim-SC_OLD-eb0c36940943390504629576c0824efcde75bffb.tar.bz2
opensim-SC_OLD-eb0c36940943390504629576c0824efcde75bffb.tar.xz
* Add documentation to BaseHttpServer.AddHTTPHandler()
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs54
-rw-r--r--OpenSim/Region/UserStatistics/WebStatsModule.cs18
2 files changed, 47 insertions, 25 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 5bd0fa5..18b53b1 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -168,13 +168,41 @@ namespace OpenSim.Framework.Servers
168 } 168 }
169 } 169 }
170 170
171 public bool AddHTTPHandler(string method, GenericHTTPMethod handler) 171 /// <summary>
172 /// Add a handler for an HTTP request
173 /// </summary>
174 ///
175 /// This handler can actually be invoked either as
176 ///
177 /// http://<hostname>:<port>/?method=<methodName>
178 ///
179 /// or
180 ///
181 /// http://<hostname>:<port><method>
182 ///
183 /// if the method starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
184 /// server will register a handler that can be invoked with either
185 ///
186 /// http://localhost:9000/?method=/object/
187 ///
188 /// or
189 ///
190 /// http://localhost:9000/object/
191 ///
192 /// <param name="methodName"></param>
193 /// <param name="handler"></param>
194 /// <returns>
195 /// true if the handler was successfully registered, false if a handler with the same name already existed.
196 /// </returns>
197 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
172 { 198 {
199 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
200
173 lock (m_HTTPHandlers) 201 lock (m_HTTPHandlers)
174 { 202 {
175 if (!m_HTTPHandlers.ContainsKey(method)) 203 if (!m_HTTPHandlers.ContainsKey(methodName))
176 { 204 {
177 m_HTTPHandlers.Add(method, handler); 205 m_HTTPHandlers.Add(methodName, handler);
178 return true; 206 return true;
179 } 207 }
180 } 208 }
@@ -517,6 +545,8 @@ namespace OpenSim.Framework.Servers
517 545
518 private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) 546 private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler)
519 { 547 {
548 //m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey);
549
520 string bestMatch = null; 550 string bestMatch = null;
521 551
522 foreach (string pattern in m_HTTPHandlers.Keys) 552 foreach (string pattern in m_HTTPHandlers.Keys)
@@ -878,7 +908,6 @@ namespace OpenSim.Framework.Servers
878 /// <returns>true if we have one, false if not</returns> 908 /// <returns>true if we have one, false if not</returns>
879 private bool DoWeHaveAHTTPHandler(string path) 909 private bool DoWeHaveAHTTPHandler(string path)
880 { 910 {
881
882 string[] pathbase = path.Split('/'); 911 string[] pathbase = path.Split('/');
883 string searchquery = "/"; 912 string searchquery = "/";
884 913
@@ -894,14 +923,13 @@ namespace OpenSim.Framework.Servers
894 923
895 string bestMatch = null; 924 string bestMatch = null;
896 925
926 //m_log.DebugFormat("[BASE HTTP HANDLER]: Checking if we have an HTTP handler for {0}", searchquery);
927
897 foreach (string pattern in m_HTTPHandlers.Keys) 928 foreach (string pattern in m_HTTPHandlers.Keys)
898 { 929 {
899
900 if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) 930 if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length)
901 { 931 {
902
903 bestMatch = pattern; 932 bestMatch = pattern;
904
905 } 933 }
906 } 934 }
907 935
@@ -911,12 +939,10 @@ namespace OpenSim.Framework.Servers
911 939
912 if (String.IsNullOrEmpty(bestMatch)) 940 if (String.IsNullOrEmpty(bestMatch))
913 { 941 {
914
915 return false; 942 return false;
916 } 943 }
917 else 944 else
918 { 945 {
919
920 return true; 946 return true;
921 } 947 }
922 } 948 }
@@ -1024,7 +1050,8 @@ namespace OpenSim.Framework.Servers
1024 catch (SocketException f) 1050 catch (SocketException f)
1025 { 1051 {
1026 // This has to be here to prevent a Linux/Mono crash 1052 // This has to be here to prevent a Linux/Mono crash
1027 m_log.WarnFormat("[BASE HTTP SERVER] XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", f); 1053 m_log.WarnFormat(
1054 "[BASE HTTP SERVER]: XmlRpcRequest issue {0}.\nNOTE: this may be spurious on Linux.", f);
1028 } 1055 }
1029 } 1056 }
1030 catch(Exception) 1057 catch(Exception)
@@ -1184,6 +1211,9 @@ namespace OpenSim.Framework.Servers
1184 1211
1185 string bestMatch = null; 1212 string bestMatch = null;
1186 1213
1214// m_log.DebugFormat(
1215// "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery);
1216
1187 foreach (string pattern in m_HTTPHandlers.Keys) 1217 foreach (string pattern in m_HTTPHandlers.Keys)
1188 { 1218 {
1189 if (searchquery.ToLower().StartsWith(pattern.ToLower())) 1219 if (searchquery.ToLower().StartsWith(pattern.ToLower()))
@@ -1196,9 +1226,7 @@ namespace OpenSim.Framework.Servers
1196 bestMatch = pattern; 1226 bestMatch = pattern;
1197 } 1227 }
1198 } 1228 }
1199 } 1229 }
1200
1201
1202 1230
1203 if (String.IsNullOrEmpty(bestMatch)) 1231 if (String.IsNullOrEmpty(bestMatch))
1204 { 1232 {
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs
index e718560..3b83cc2 100644
--- a/OpenSim/Region/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs
@@ -69,21 +69,19 @@ namespace OpenSim.Region.UserStatistics
69 private string m_loglines = String.Empty; 69 private string m_loglines = String.Empty;
70 private volatile int lastHit = 12000; 70 private volatile int lastHit = 12000;
71 71
72
73 public virtual void Initialise(Scene scene, IConfigSource config) 72 public virtual void Initialise(Scene scene, IConfigSource config)
74 { 73 {
75 IConfig cnfg; 74 IConfig cnfg;
76 try 75 try
77 { 76 {
78 cnfg = config.Configs["WebStats"]; 77 cnfg = config.Configs["WebStats"];
79 enabled = cnfg.GetBoolean("enabled", false); 78 enabled = cnfg.GetBoolean("enabled", false);
80
81
82 } 79 }
83 catch (Exception) 80 catch (Exception)
84 { 81 {
85 enabled = false; 82 enabled = false;
86 } 83 }
84
87 if (!enabled) 85 if (!enabled)
88 { 86 {
89 return; 87 return;
@@ -130,14 +128,12 @@ namespace OpenSim.Region.UserStatistics
130 128
131 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest); 129 scene.CommsManager.HttpServer.AddHTTPHandler("/SStats/", HandleStatsRequest);
132 scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); 130 scene.CommsManager.HttpServer.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest);
133
134
135 } 131 }
132
136 m_scene.Add(scene); 133 m_scene.Add(scene);
137 m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID)); 134 m_simstatsCounters.Add(scene.RegionInfo.RegionID, new USimStatsData(scene.RegionInfo.RegionID));
138 scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket; 135 scene.StatsReporter.OnSendStatsResult += ReceiveClassicSimStatsPacket;
139 } 136 }
140
141 } 137 }
142 138
143 public void ReceiveClassicSimStatsPacket(SimStats stats) 139 public void ReceiveClassicSimStatsPacket(SimStats stats)
@@ -168,10 +164,10 @@ namespace OpenSim.Region.UserStatistics
168 } 164 }
169 } 165 }
170 catch (KeyNotFoundException) 166 catch (KeyNotFoundException)
171 { 167 {
172
173 } 168 }
174 } 169 }
170
175 public Hashtable HandleUnknownCAPSRequest(Hashtable request) 171 public Hashtable HandleUnknownCAPSRequest(Hashtable request)
176 { 172 {
177 //string regpath = request["uri"].ToString(); 173 //string regpath = request["uri"].ToString();
@@ -247,9 +243,7 @@ namespace OpenSim.Region.UserStatistics
247 243
248 return responsedata; 244 return responsedata;
249 } 245 }
250
251 246
252
253 public void CheckAndUpdateDatabase(SqliteConnection db) 247 public void CheckAndUpdateDatabase(SqliteConnection db)
254 { 248 {
255 lock (db) 249 lock (db)