aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
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 /OpenSim/Framework/Servers
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()
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs54
1 files changed, 41 insertions, 13 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 {