diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 272 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | 22 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/MainServer.cs | 148 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/VersionInfo.cs | 2 |
4 files changed, 319 insertions, 125 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 788a0b9..b3e31a6 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -54,8 +54,23 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); | 55 | private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// Gets or sets the debug level. | ||
59 | /// </summary> | ||
60 | /// <value> | ||
61 | /// See MainServer.DebugLevel. | ||
62 | /// </value> | ||
57 | public int DebugLevel { get; set; } | 63 | public int DebugLevel { get; set; } |
58 | 64 | ||
65 | /// <summary> | ||
66 | /// Request number for diagnostic purposes. | ||
67 | /// </summary> | ||
68 | /// <remarks> | ||
69 | /// This is an internal number. In some debug situations an external number may also be supplied in the | ||
70 | /// opensim-request-id header but we are not currently logging this. | ||
71 | /// </remarks> | ||
72 | public int RequestNumber { get; private set; } | ||
73 | |||
59 | private volatile int NotSocketErrors = 0; | 74 | private volatile int NotSocketErrors = 0; |
60 | public volatile bool HTTPDRunning = false; | 75 | public volatile bool HTTPDRunning = false; |
61 | 76 | ||
@@ -67,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
67 | protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); | 82 | protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); |
68 | protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); | 83 | protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); |
69 | protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); | 84 | protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); |
70 | protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); | 85 | // protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); |
71 | protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = | 86 | protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = |
72 | new Dictionary<string, PollServiceEventArgs>(); | 87 | new Dictionary<string, PollServiceEventArgs>(); |
73 | 88 | ||
@@ -245,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
245 | return new List<string>(m_pollHandlers.Keys); | 260 | return new List<string>(m_pollHandlers.Keys); |
246 | } | 261 | } |
247 | 262 | ||
248 | // Note that the agent string is provided simply to differentiate | 263 | // // Note that the agent string is provided simply to differentiate |
249 | // the handlers - it is NOT required to be an actual agent header | 264 | // // the handlers - it is NOT required to be an actual agent header |
250 | // value. | 265 | // // value. |
251 | public bool AddAgentHandler(string agent, IHttpAgentHandler handler) | 266 | // public bool AddAgentHandler(string agent, IHttpAgentHandler handler) |
252 | { | 267 | // { |
253 | lock (m_agentHandlers) | 268 | // lock (m_agentHandlers) |
254 | { | 269 | // { |
255 | if (!m_agentHandlers.ContainsKey(agent)) | 270 | // if (!m_agentHandlers.ContainsKey(agent)) |
256 | { | 271 | // { |
257 | m_agentHandlers.Add(agent, handler); | 272 | // m_agentHandlers.Add(agent, handler); |
258 | return true; | 273 | // return true; |
259 | } | 274 | // } |
260 | } | 275 | // } |
261 | 276 | // | |
262 | //must already have a handler for that path so return false | 277 | // //must already have a handler for that path so return false |
263 | return false; | 278 | // return false; |
264 | } | 279 | // } |
265 | 280 | // | |
266 | public List<string> GetAgentHandlerKeys() | 281 | // public List<string> GetAgentHandlerKeys() |
267 | { | 282 | // { |
268 | lock (m_agentHandlers) | 283 | // lock (m_agentHandlers) |
269 | return new List<string>(m_agentHandlers.Keys); | 284 | // return new List<string>(m_agentHandlers.Keys); |
270 | } | 285 | // } |
271 | 286 | ||
272 | public bool AddLLSDHandler(string path, LLSDMethod handler) | 287 | public bool AddLLSDHandler(string path, LLSDMethod handler) |
273 | { | 288 | { |
@@ -296,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
296 | 311 | ||
297 | private void OnRequest(object source, RequestEventArgs args) | 312 | private void OnRequest(object source, RequestEventArgs args) |
298 | { | 313 | { |
314 | RequestNumber++; | ||
315 | |||
299 | try | 316 | try |
300 | { | 317 | { |
301 | IHttpClientContext context = (IHttpClientContext)source; | 318 | IHttpClientContext context = (IHttpClientContext)source; |
@@ -406,7 +423,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
406 | string requestMethod = request.HttpMethod; | 423 | string requestMethod = request.HttpMethod; |
407 | string uriString = request.RawUrl; | 424 | string uriString = request.RawUrl; |
408 | 425 | ||
409 | // string reqnum = "unknown"; | ||
410 | int requestStartTick = Environment.TickCount; | 426 | int requestStartTick = Environment.TickCount; |
411 | 427 | ||
412 | // Will be adjusted later on. | 428 | // Will be adjusted later on. |
@@ -423,22 +439,22 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
423 | 439 | ||
424 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); | 440 | Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); |
425 | 441 | ||
426 | // This is the REST agent interface. We require an agent to properly identify | 442 | // // This is the REST agent interface. We require an agent to properly identify |
427 | // itself. If the REST handler recognizes the prefix it will attempt to | 443 | // // itself. If the REST handler recognizes the prefix it will attempt to |
428 | // satisfy the request. If it is not recognizable, and no damage has occurred | 444 | // // satisfy the request. If it is not recognizable, and no damage has occurred |
429 | // the request can be passed through to the other handlers. This is a low | 445 | // // the request can be passed through to the other handlers. This is a low |
430 | // probability event; if a request is matched it is normally expected to be | 446 | // // probability event; if a request is matched it is normally expected to be |
431 | // handled | 447 | // // handled |
432 | IHttpAgentHandler agentHandler; | 448 | // IHttpAgentHandler agentHandler; |
433 | 449 | // | |
434 | if (TryGetAgentHandler(request, response, out agentHandler)) | 450 | // if (TryGetAgentHandler(request, response, out agentHandler)) |
435 | { | 451 | // { |
436 | if (HandleAgentRequest(agentHandler, request, response)) | 452 | // if (HandleAgentRequest(agentHandler, request, response)) |
437 | { | 453 | // { |
438 | requestEndTick = Environment.TickCount; | 454 | // requestEndTick = Environment.TickCount; |
439 | return; | 455 | // return; |
440 | } | 456 | // } |
441 | } | 457 | // } |
442 | 458 | ||
443 | //response.KeepAlive = true; | 459 | //response.KeepAlive = true; |
444 | response.SendChunked = false; | 460 | response.SendChunked = false; |
@@ -450,9 +466,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
450 | if (TryGetStreamHandler(handlerKey, out requestHandler)) | 466 | if (TryGetStreamHandler(handlerKey, out requestHandler)) |
451 | { | 467 | { |
452 | if (DebugLevel >= 3) | 468 | if (DebugLevel >= 3) |
453 | m_log.DebugFormat( | 469 | LogIncomingToStreamHandler(request, requestHandler); |
454 | "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", | ||
455 | request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); | ||
456 | 470 | ||
457 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. | 471 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. |
458 | 472 | ||
@@ -532,8 +546,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
532 | 546 | ||
533 | if (DebugLevel >= 3) | 547 | if (DebugLevel >= 3) |
534 | m_log.DebugFormat( | 548 | m_log.DebugFormat( |
535 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | 549 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", |
536 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | 550 | RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); |
537 | 551 | ||
538 | buffer = HandleHTTPRequest(request, response); | 552 | buffer = HandleHTTPRequest(request, response); |
539 | break; | 553 | break; |
@@ -544,8 +558,8 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
544 | 558 | ||
545 | if (DebugLevel >= 3) | 559 | if (DebugLevel >= 3) |
546 | m_log.DebugFormat( | 560 | m_log.DebugFormat( |
547 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | 561 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", |
548 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | 562 | RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); |
549 | 563 | ||
550 | buffer = HandleLLSDRequests(request, response); | 564 | buffer = HandleLLSDRequests(request, response); |
551 | break; | 565 | break; |
@@ -564,9 +578,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
564 | if (DoWeHaveALLSDHandler(request.RawUrl)) | 578 | if (DoWeHaveALLSDHandler(request.RawUrl)) |
565 | { | 579 | { |
566 | if (DebugLevel >= 3) | 580 | if (DebugLevel >= 3) |
567 | m_log.DebugFormat( | 581 | LogIncomingToContentTypeHandler(request); |
568 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
569 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
570 | 582 | ||
571 | buffer = HandleLLSDRequests(request, response); | 583 | buffer = HandleLLSDRequests(request, response); |
572 | } | 584 | } |
@@ -574,18 +586,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
574 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) | 586 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) |
575 | { | 587 | { |
576 | if (DebugLevel >= 3) | 588 | if (DebugLevel >= 3) |
577 | m_log.DebugFormat( | 589 | LogIncomingToContentTypeHandler(request); |
578 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
579 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
580 | 590 | ||
581 | buffer = HandleHTTPRequest(request, response); | 591 | buffer = HandleHTTPRequest(request, response); |
582 | } | 592 | } |
583 | else | 593 | else |
584 | { | 594 | { |
585 | if (DebugLevel >= 3) | 595 | if (DebugLevel >= 3) |
586 | m_log.DebugFormat( | 596 | LogIncomingToXmlRpcHandler(request); |
587 | "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", | ||
588 | request.HttpMethod, request.Url.PathAndQuery); | ||
589 | 597 | ||
590 | // generic login request. | 598 | // generic login request. |
591 | buffer = HandleXmlRpcRequests(request, response); | 599 | buffer = HandleXmlRpcRequests(request, response); |
@@ -629,11 +637,11 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
629 | } | 637 | } |
630 | catch (IOException e) | 638 | catch (IOException e) |
631 | { | 639 | { |
632 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); | 640 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); |
633 | } | 641 | } |
634 | catch (Exception e) | 642 | catch (Exception e) |
635 | { | 643 | { |
636 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.Message), e); | 644 | m_log.Error(String.Format("[BASE HTTP SERVER]: HandleRequest() threw {0} ", e.StackTrace), e); |
637 | SendHTML500(response); | 645 | SendHTML500(response); |
638 | } | 646 | } |
639 | finally | 647 | finally |
@@ -644,17 +652,93 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
644 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) | 652 | if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) |
645 | { | 653 | { |
646 | m_log.InfoFormat( | 654 | m_log.InfoFormat( |
647 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", | 655 | "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", |
656 | RequestNumber, | ||
648 | requestMethod, | 657 | requestMethod, |
649 | uriString, | 658 | uriString, |
650 | requestHandler != null ? requestHandler.Name : "", | 659 | requestHandler != null ? requestHandler.Name : "", |
651 | requestHandler != null ? requestHandler.Description : "", | 660 | requestHandler != null ? requestHandler.Description : "", |
652 | request.RemoteIPEndPoint.ToString(), | 661 | request.RemoteIPEndPoint, |
662 | tickdiff); | ||
663 | } | ||
664 | else if (DebugLevel >= 4) | ||
665 | { | ||
666 | m_log.DebugFormat( | ||
667 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms", | ||
668 | RequestNumber, | ||
669 | Port, | ||
653 | tickdiff); | 670 | tickdiff); |
654 | } | 671 | } |
655 | } | 672 | } |
656 | } | 673 | } |
657 | 674 | ||
675 | private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) | ||
676 | { | ||
677 | m_log.DebugFormat( | ||
678 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}", | ||
679 | RequestNumber, | ||
680 | Port, | ||
681 | request.HttpMethod, | ||
682 | request.Url.PathAndQuery, | ||
683 | requestHandler.Name, | ||
684 | requestHandler.Description, | ||
685 | request.RemoteIPEndPoint); | ||
686 | |||
687 | if (DebugLevel >= 5) | ||
688 | LogIncomingInDetail(request); | ||
689 | } | ||
690 | |||
691 | private void LogIncomingToContentTypeHandler(OSHttpRequest request) | ||
692 | { | ||
693 | m_log.DebugFormat( | ||
694 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}", | ||
695 | RequestNumber, | ||
696 | Port, | ||
697 | request.ContentType, | ||
698 | request.HttpMethod, | ||
699 | request.Url.PathAndQuery, | ||
700 | request.RemoteIPEndPoint); | ||
701 | |||
702 | if (DebugLevel >= 5) | ||
703 | LogIncomingInDetail(request); | ||
704 | } | ||
705 | |||
706 | private void LogIncomingToXmlRpcHandler(OSHttpRequest request) | ||
707 | { | ||
708 | m_log.DebugFormat( | ||
709 | "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}", | ||
710 | RequestNumber, | ||
711 | Port, | ||
712 | request.HttpMethod, | ||
713 | request.Url.PathAndQuery, | ||
714 | request.RemoteIPEndPoint); | ||
715 | |||
716 | if (DebugLevel >= 5) | ||
717 | LogIncomingInDetail(request); | ||
718 | } | ||
719 | |||
720 | private void LogIncomingInDetail(OSHttpRequest request) | ||
721 | { | ||
722 | using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8)) | ||
723 | { | ||
724 | string output; | ||
725 | |||
726 | if (DebugLevel == 5) | ||
727 | { | ||
728 | const int sampleLength = 80; | ||
729 | char[] sampleChars = new char[sampleLength]; | ||
730 | reader.Read(sampleChars, 0, sampleLength); | ||
731 | output = new string(sampleChars); | ||
732 | } | ||
733 | else | ||
734 | { | ||
735 | output = reader.ReadToEnd(); | ||
736 | } | ||
737 | |||
738 | m_log.DebugFormat("[BASE HTTP SERVER]: {0}...", output.Replace("\n", @"\n")); | ||
739 | } | ||
740 | } | ||
741 | |||
658 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) | 742 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) |
659 | { | 743 | { |
660 | string bestMatch = null; | 744 | string bestMatch = null; |
@@ -747,24 +831,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
747 | } | 831 | } |
748 | } | 832 | } |
749 | 833 | ||
750 | private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) | 834 | // private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) |
751 | { | 835 | // { |
752 | agentHandler = null; | 836 | // agentHandler = null; |
753 | 837 | // | |
754 | lock (m_agentHandlers) | 838 | // lock (m_agentHandlers) |
755 | { | 839 | // { |
756 | foreach (IHttpAgentHandler handler in m_agentHandlers.Values) | 840 | // foreach (IHttpAgentHandler handler in m_agentHandlers.Values) |
757 | { | 841 | // { |
758 | if (handler.Match(request, response)) | 842 | // if (handler.Match(request, response)) |
759 | { | 843 | // { |
760 | agentHandler = handler; | 844 | // agentHandler = handler; |
761 | return true; | 845 | // return true; |
762 | } | 846 | // } |
763 | } | 847 | // } |
764 | } | 848 | // } |
765 | 849 | // | |
766 | return false; | 850 | // return false; |
767 | } | 851 | // } |
768 | 852 | ||
769 | /// <summary> | 853 | /// <summary> |
770 | /// Try all the registered xmlrpc handlers when an xmlrpc request is received. | 854 | /// Try all the registered xmlrpc handlers when an xmlrpc request is received. |
@@ -1737,21 +1821,21 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1737 | m_pollHandlers.Remove(path); | 1821 | m_pollHandlers.Remove(path); |
1738 | } | 1822 | } |
1739 | 1823 | ||
1740 | public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) | 1824 | // public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) |
1741 | { | 1825 | // { |
1742 | lock (m_agentHandlers) | 1826 | // lock (m_agentHandlers) |
1743 | { | 1827 | // { |
1744 | IHttpAgentHandler foundHandler; | 1828 | // IHttpAgentHandler foundHandler; |
1745 | 1829 | // | |
1746 | if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) | 1830 | // if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) |
1747 | { | 1831 | // { |
1748 | m_agentHandlers.Remove(agent); | 1832 | // m_agentHandlers.Remove(agent); |
1749 | return true; | 1833 | // return true; |
1750 | } | 1834 | // } |
1751 | } | 1835 | // } |
1752 | 1836 | // | |
1753 | return false; | 1837 | // return false; |
1754 | } | 1838 | // } |
1755 | 1839 | ||
1756 | public void RemoveXmlRPCHandler(string method) | 1840 | public void RemoveXmlRPCHandler(string method) |
1757 | { | 1841 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index db58f6f..0bd3aae 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs | |||
@@ -41,10 +41,10 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
41 | uint Port { get; } | 41 | uint Port { get; } |
42 | bool UseSSL { get; } | 42 | bool UseSSL { get; } |
43 | 43 | ||
44 | // Note that the agent string is provided simply to differentiate | 44 | // // Note that the agent string is provided simply to differentiate |
45 | // the handlers - it is NOT required to be an actual agent header | 45 | // // the handlers - it is NOT required to be an actual agent header |
46 | // value. | 46 | // // value. |
47 | bool AddAgentHandler(string agent, IHttpAgentHandler handler); | 47 | // bool AddAgentHandler(string agent, IHttpAgentHandler handler); |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Add a handler for an HTTP request. | 50 | /// Add a handler for an HTTP request. |
@@ -106,13 +106,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
106 | 106 | ||
107 | bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); | 107 | bool SetDefaultLLSDHandler(DefaultLLSDMethod handler); |
108 | 108 | ||
109 | /// <summary> | 109 | // /// <summary> |
110 | /// Remove the agent if it is registered. | 110 | // /// Remove the agent if it is registered. |
111 | /// </summary> | 111 | // /// </summary> |
112 | /// <param name="agent"></param> | 112 | // /// <param name="agent"></param> |
113 | /// <param name="handler"></param> | 113 | // /// <param name="handler"></param> |
114 | /// <returns></returns> | 114 | // /// <returns></returns> |
115 | bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); | 115 | // bool RemoveAgentHandler(string agent, IHttpAgentHandler handler); |
116 | 116 | ||
117 | /// <summary> | 117 | /// <summary> |
118 | /// Remove an HTTP handler | 118 | /// Remove an HTTP handler |
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs index 8dc0e3a..ae7d515 100644 --- a/OpenSim/Framework/Servers/MainServer.cs +++ b/OpenSim/Framework/Servers/MainServer.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Text; | ||
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
@@ -47,9 +48,12 @@ namespace OpenSim.Framework.Servers | |||
47 | /// Control the printing of certain debug messages. | 48 | /// Control the printing of certain debug messages. |
48 | /// </summary> | 49 | /// </summary> |
49 | /// <remarks> | 50 | /// <remarks> |
50 | /// If DebugLevel >= 1, then short warnings are logged when receiving bad input data. | 51 | /// If DebugLevel >= 1 then short warnings are logged when receiving bad input data. |
51 | /// If DebugLevel >= 2, then long warnings are logged when receiving bad input data. | 52 | /// If DebugLevel >= 2 then long warnings are logged when receiving bad input data. |
52 | /// If DebugLevel >= 3, then short notices about all incoming non-poll HTTP requests are logged. | 53 | /// If DebugLevel >= 3 then short notices about all incoming non-poll HTTP requests are logged. |
54 | /// If DebugLevel >= 4 then the time taken to fulfill the request is logged. | ||
55 | /// If DebugLevel >= 5 then the start of the body of incoming non-poll HTTP requests will be logged. | ||
56 | /// If DebugLevel >= 6 then the entire body of incoming non-poll HTTP requests will be logged. | ||
53 | /// </remarks> | 57 | /// </remarks> |
54 | public static int DebugLevel | 58 | public static int DebugLevel |
55 | { | 59 | { |
@@ -101,17 +105,28 @@ namespace OpenSim.Framework.Servers | |||
101 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } | 105 | get { return new Dictionary<uint, BaseHttpServer>(m_Servers); } |
102 | } | 106 | } |
103 | 107 | ||
104 | |||
105 | public static void RegisterHttpConsoleCommands(ICommandConsole console) | 108 | public static void RegisterHttpConsoleCommands(ICommandConsole console) |
106 | { | 109 | { |
107 | console.Commands.AddCommand( | 110 | console.Commands.AddCommand( |
108 | "Debug", false, "debug http", "debug http [<level>]", | 111 | "Comms", false, "show http-handlers", |
109 | "Turn on inbound non-poll http request debugging.", | 112 | "show http-handlers", |
110 | "If level <= 0, then no extra logging is done.\n" | 113 | "Show all registered http handlers", HandleShowHttpHandlersCommand); |
111 | + "If level >= 1, then short warnings are logged when receiving bad input data.\n" | 114 | |
112 | + "If level >= 2, then long warnings are logged when receiving bad input data.\n" | 115 | console.Commands.AddCommand( |
113 | + "If level >= 3, then short notices about all incoming non-poll HTTP requests are logged.\n" | 116 | "Debug", false, "debug http", "debug http <in|out|all> [<level>]", |
114 | + "If no level is specified then the current level is returned.", | 117 | "Turn on http request logging.", |
118 | "If in or all and\n" | ||
119 | + " level <= 0 then no extra logging is done.\n" | ||
120 | + " level >= 1 then short warnings are logged when receiving bad input data.\n" | ||
121 | + " level >= 2 then long warnings are logged when receiving bad input data.\n" | ||
122 | + " level >= 3 then short notices about all incoming non-poll HTTP requests are logged.\n" | ||
123 | + " level >= 4 then the time taken to fulfill the request is logged.\n" | ||
124 | + " level >= 5 then a sample from the beginning of the incoming data is logged.\n" | ||
125 | + " level >= 6 then the entire incoming data is logged.\n" | ||
126 | + " no level is specified then the current level is returned.\n\n" | ||
127 | + "If out or all and\n" | ||
128 | + " level >= 3 then short notices about all outgoing requests going through WebUtil are logged.\n" | ||
129 | + " level >= 4 then the time taken to fulfill the request is logged.\n", | ||
115 | HandleDebugHttpCommand); | 130 | HandleDebugHttpCommand); |
116 | } | 131 | } |
117 | 132 | ||
@@ -119,25 +134,120 @@ namespace OpenSim.Framework.Servers | |||
119 | /// Turn on some debugging values for OpenSim. | 134 | /// Turn on some debugging values for OpenSim. |
120 | /// </summary> | 135 | /// </summary> |
121 | /// <param name="args"></param> | 136 | /// <param name="args"></param> |
122 | private static void HandleDebugHttpCommand(string module, string[] args) | 137 | private static void HandleDebugHttpCommand(string module, string[] cmdparams) |
123 | { | 138 | { |
124 | if (args.Length == 3) | 139 | if (cmdparams.Length < 3) |
140 | { | ||
141 | MainConsole.Instance.Output("Usage: debug http <in|out|all> 0..6"); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | bool inReqs = false; | ||
146 | bool outReqs = false; | ||
147 | bool allReqs = false; | ||
148 | |||
149 | string subCommand = cmdparams[2]; | ||
150 | |||
151 | if (subCommand.ToLower() == "in") | ||
152 | { | ||
153 | inReqs = true; | ||
154 | } | ||
155 | else if (subCommand.ToLower() == "out") | ||
156 | { | ||
157 | outReqs = true; | ||
158 | } | ||
159 | else if (subCommand.ToLower() == "all") | ||
160 | { | ||
161 | allReqs = true; | ||
162 | } | ||
163 | else | ||
125 | { | 164 | { |
165 | MainConsole.Instance.Output("You must specify in, out or all"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | if (cmdparams.Length >= 4) | ||
170 | { | ||
171 | string rawNewDebug = cmdparams[3]; | ||
126 | int newDebug; | 172 | int newDebug; |
127 | if (int.TryParse(args[2], out newDebug)) | 173 | |
174 | if (!int.TryParse(rawNewDebug, out newDebug)) | ||
175 | { | ||
176 | MainConsole.Instance.OutputFormat("{0} is not a valid debug level", rawNewDebug); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | if (newDebug < 0 || newDebug > 6) | ||
181 | { | ||
182 | MainConsole.Instance.OutputFormat("{0} is outside the valid debug level range of 0..6", newDebug); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | if (allReqs || inReqs) | ||
128 | { | 187 | { |
129 | MainServer.DebugLevel = newDebug; | 188 | MainServer.DebugLevel = newDebug; |
130 | MainConsole.Instance.OutputFormat("Debug http level set to {0}", newDebug); | 189 | MainConsole.Instance.OutputFormat("IN debug level set to {0}", newDebug); |
190 | } | ||
191 | |||
192 | if (allReqs || outReqs) | ||
193 | { | ||
194 | WebUtil.DebugLevel = newDebug; | ||
195 | MainConsole.Instance.OutputFormat("OUT debug level set to {0}", newDebug); | ||
131 | } | 196 | } |
132 | } | 197 | } |
133 | else if (args.Length == 2) | 198 | else |
134 | { | 199 | { |
135 | MainConsole.Instance.OutputFormat("Current debug http level is {0}", MainServer.DebugLevel); | 200 | if (allReqs || inReqs) |
201 | MainConsole.Instance.OutputFormat("Current IN debug level is {0}", MainServer.DebugLevel); | ||
202 | |||
203 | if (allReqs || outReqs) | ||
204 | MainConsole.Instance.OutputFormat("Current OUT debug level is {0}", WebUtil.DebugLevel); | ||
136 | } | 205 | } |
137 | else | 206 | } |
207 | |||
208 | private static void HandleShowHttpHandlersCommand(string module, string[] args) | ||
209 | { | ||
210 | if (args.Length != 2) | ||
211 | { | ||
212 | MainConsole.Instance.Output("Usage: show http-handlers"); | ||
213 | return; | ||
214 | } | ||
215 | |||
216 | StringBuilder handlers = new StringBuilder(); | ||
217 | |||
218 | lock (m_Servers) | ||
138 | { | 219 | { |
139 | MainConsole.Instance.Output("Usage: debug http 0..3"); | 220 | foreach (BaseHttpServer httpServer in m_Servers.Values) |
221 | { | ||
222 | handlers.AppendFormat( | ||
223 | "Registered HTTP Handlers for server at {0}:{1}\n", httpServer.ListenIPAddress, httpServer.Port); | ||
224 | |||
225 | handlers.AppendFormat("* XMLRPC:\n"); | ||
226 | foreach (String s in httpServer.GetXmlRpcHandlerKeys()) | ||
227 | handlers.AppendFormat("\t{0}\n", s); | ||
228 | |||
229 | handlers.AppendFormat("* HTTP:\n"); | ||
230 | List<String> poll = httpServer.GetPollServiceHandlerKeys(); | ||
231 | foreach (String s in httpServer.GetHTTPHandlerKeys()) | ||
232 | handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); | ||
233 | |||
234 | // handlers.AppendFormat("* Agent:\n"); | ||
235 | // foreach (String s in httpServer.GetAgentHandlerKeys()) | ||
236 | // handlers.AppendFormat("\t{0}\n", s); | ||
237 | |||
238 | handlers.AppendFormat("* LLSD:\n"); | ||
239 | foreach (String s in httpServer.GetLLSDHandlerKeys()) | ||
240 | handlers.AppendFormat("\t{0}\n", s); | ||
241 | |||
242 | handlers.AppendFormat("* StreamHandlers ({0}):\n", httpServer.GetStreamHandlerKeys().Count); | ||
243 | foreach (String s in httpServer.GetStreamHandlerKeys()) | ||
244 | handlers.AppendFormat("\t{0}\n", s); | ||
245 | |||
246 | handlers.Append("\n"); | ||
247 | } | ||
140 | } | 248 | } |
249 | |||
250 | MainConsole.Instance.Output(handlers.ToString()); | ||
141 | } | 251 | } |
142 | 252 | ||
143 | /// <summary> | 253 | /// <summary> |
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs index 016a174..bb094ed 100644 --- a/OpenSim/Framework/Servers/VersionInfo.cs +++ b/OpenSim/Framework/Servers/VersionInfo.cs | |||
@@ -29,7 +29,7 @@ namespace OpenSim | |||
29 | { | 29 | { |
30 | public class VersionInfo | 30 | public class VersionInfo |
31 | { | 31 | { |
32 | private const string VERSION_NUMBER = "0.7.4CM"; | 32 | private const string VERSION_NUMBER = "0.7.5CM"; |
33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; | 33 | private const Flavour VERSION_FLAVOUR = Flavour.Dev; |
34 | 34 | ||
35 | public enum Flavour | 35 | public enum Flavour |