diff options
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index d4ee7ba..ccec9b7 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -143,6 +143,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | public List<string> GetStreamHandlerKeys() | ||
147 | { | ||
148 | return new List<string>(m_streamHandlers.Keys); | ||
149 | } | ||
150 | |||
146 | private static string GetHandlerKey(string httpMethod, string path) | 151 | private static string GetHandlerKey(string httpMethod, string path) |
147 | { | 152 | { |
148 | return httpMethod + ":" + path; | 153 | return httpMethod + ":" + path; |
@@ -179,6 +184,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
179 | } | 184 | } |
180 | } | 185 | } |
181 | 186 | ||
187 | public List<string> GetXmlRpcHandlerKeys() | ||
188 | { | ||
189 | return new List<string>(m_rpcHandlers.Keys); | ||
190 | } | ||
191 | |||
182 | public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) | 192 | public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) |
183 | { | 193 | { |
184 | //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); | 194 | //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); |
@@ -196,6 +206,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
196 | return false; | 206 | return false; |
197 | } | 207 | } |
198 | 208 | ||
209 | public List<string> GetHTTPHandlerKeys() | ||
210 | { | ||
211 | return new List<string>(m_HTTPHandlers.Keys); | ||
212 | } | ||
213 | |||
214 | |||
199 | public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) | 215 | public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) |
200 | { | 216 | { |
201 | bool pollHandlerResult = false; | 217 | bool pollHandlerResult = false; |
@@ -214,6 +230,12 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
214 | return false; | 230 | return false; |
215 | } | 231 | } |
216 | 232 | ||
233 | public List<string> GetPollServiceHandlerKeys() | ||
234 | { | ||
235 | return new List<string>(m_pollHandlers.Keys); | ||
236 | } | ||
237 | |||
238 | |||
217 | // Note that the agent string is provided simply to differentiate | 239 | // Note that the agent string is provided simply to differentiate |
218 | // the handlers - it is NOT required to be an actual agent header | 240 | // the handlers - it is NOT required to be an actual agent header |
219 | // value. | 241 | // value. |
@@ -232,6 +254,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
232 | return false; | 254 | return false; |
233 | } | 255 | } |
234 | 256 | ||
257 | public List<string> GetAgentHandlerKeys() | ||
258 | { | ||
259 | return new List<string>(m_agentHandlers.Keys); | ||
260 | } | ||
261 | |||
235 | public bool AddLLSDHandler(string path, LLSDMethod handler) | 262 | public bool AddLLSDHandler(string path, LLSDMethod handler) |
236 | { | 263 | { |
237 | lock (m_llsdHandlers) | 264 | lock (m_llsdHandlers) |
@@ -245,6 +272,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
245 | return false; | 272 | return false; |
246 | } | 273 | } |
247 | 274 | ||
275 | public List<string> GetLLSDHandlerKeys() | ||
276 | { | ||
277 | return new List<string>(m_llsdHandlers.Keys); | ||
278 | } | ||
279 | |||
248 | public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) | 280 | public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) |
249 | { | 281 | { |
250 | m_defaultLlsdHandler = handler; | 282 | m_defaultLlsdHandler = handler; |
@@ -346,6 +378,22 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
346 | /// <param name="response"></param> | 378 | /// <param name="response"></param> |
347 | public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) | 379 | public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) |
348 | { | 380 | { |
381 | if (request.HttpMethod == String.Empty) // Can't handle empty requests, not wasting a thread | ||
382 | { | ||
383 | try | ||
384 | { | ||
385 | SendHTML500(response); | ||
386 | } | ||
387 | catch | ||
388 | { | ||
389 | } | ||
390 | |||
391 | return; | ||
392 | } | ||
393 | |||
394 | string requestMethod = request.HttpMethod; | ||
395 | string uriString = request.RawUrl; | ||
396 | |||
349 | string reqnum = "unknown"; | 397 | string reqnum = "unknown"; |
350 | int tickstart = Environment.TickCount; | 398 | int tickstart = Environment.TickCount; |
351 | 399 | ||
@@ -463,7 +511,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
463 | 511 | ||
464 | request.InputStream.Close(); | 512 | request.InputStream.Close(); |
465 | 513 | ||
466 | // HTTP IN support. The script engine taes it from here | 514 | // HTTP IN support. The script engine takes it from here |
467 | // Nothing to worry about for us. | 515 | // Nothing to worry about for us. |
468 | // | 516 | // |
469 | if (buffer == null) | 517 | if (buffer == null) |
@@ -577,19 +625,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
577 | { | 625 | { |
578 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw ", e); | 626 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw ", e); |
579 | } | 627 | } |
580 | catch (InvalidOperationException e) | 628 | catch (Exception e) |
581 | { | 629 | { |
582 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e); | 630 | m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw " + e.ToString()); |
583 | SendHTML500(response); | 631 | SendHTML500(response); |
584 | } | 632 | } |
585 | finally | 633 | finally |
586 | { | 634 | { |
587 | // Every month or so this will wrap and give bad numbers, not really a problem | 635 | // Every month or so this will wrap and give bad numbers, not really a problem |
588 | // since its just for reporting, 200ms limit can be adjusted | 636 | // since its just for reporting, tickdiff limit can be adjusted |
589 | int tickdiff = Environment.TickCount - tickstart; | 637 | int tickdiff = Environment.TickCount - tickstart; |
590 | if (tickdiff > 500) | 638 | if (tickdiff > 3000) |
591 | m_log.InfoFormat( | 639 | m_log.InfoFormat( |
592 | "[BASE HTTP SERVER]: slow request <{0}> for {1} took {2} ms", reqnum, request.RawUrl, tickdiff); | 640 | "[BASE HTTP SERVER]: slow {0} request for {1} from {2} took {3} ms", requestMethod, uriString, request.RemoteIPEndPoint.ToString(), tickdiff); |
593 | } | 641 | } |
594 | } | 642 | } |
595 | 643 | ||
@@ -753,7 +801,19 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
753 | if (methodWasFound) | 801 | if (methodWasFound) |
754 | { | 802 | { |
755 | xmlRprcRequest.Params.Add(request.Url); // Param[2] | 803 | xmlRprcRequest.Params.Add(request.Url); // Param[2] |
756 | xmlRprcRequest.Params.Add(request.Headers.Get("X-Forwarded-For")); // Param[3] | 804 | |
805 | string xff = "X-Forwarded-For"; | ||
806 | string xfflower = xff.ToLower(); | ||
807 | foreach (string s in request.Headers.AllKeys) | ||
808 | { | ||
809 | if (s != null && s.Equals(xfflower)) | ||
810 | { | ||
811 | xff = xfflower; | ||
812 | break; | ||
813 | } | ||
814 | } | ||
815 | xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] | ||
816 | |||
757 | 817 | ||
758 | try | 818 | try |
759 | { | 819 | { |