diff options
author | Justin Clark-Casey (justincc) | 2012-09-11 21:48:02 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-11 21:48:51 +0100 |
commit | 25111e703f54d84c7c51e32db1f94332ea3ffd00 (patch) | |
tree | f0fd2496b35cea00b7f737ba61af9f72f22da0f3 /OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |
parent | refactoring to allow Scene.GetLandData to accept Vector3 as an argument. Note... (diff) | |
download | opensim-SC-25111e703f54d84c7c51e32db1f94332ea3ffd00.zip opensim-SC-25111e703f54d84c7c51e32db1f94332ea3ffd00.tar.gz opensim-SC-25111e703f54d84c7c51e32db1f94332ea3ffd00.tar.bz2 opensim-SC-25111e703f54d84c7c51e32db1f94332ea3ffd00.tar.xz |
Add levels 4 and 5 to "debug http" console command that will log a sample of incoming request data and the entire incoming data respectively.
See "help debug http" for more details.
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index f57ea76..c81e283 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -449,9 +449,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
449 | if (TryGetStreamHandler(handlerKey, out requestHandler)) | 449 | if (TryGetStreamHandler(handlerKey, out requestHandler)) |
450 | { | 450 | { |
451 | if (DebugLevel >= 3) | 451 | if (DebugLevel >= 3) |
452 | m_log.DebugFormat( | 452 | LogIncomingToStreamHandler(request, requestHandler); |
453 | "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", | ||
454 | request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); | ||
455 | 453 | ||
456 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. | 454 | response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. |
457 | 455 | ||
@@ -563,9 +561,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
563 | if (DoWeHaveALLSDHandler(request.RawUrl)) | 561 | if (DoWeHaveALLSDHandler(request.RawUrl)) |
564 | { | 562 | { |
565 | if (DebugLevel >= 3) | 563 | if (DebugLevel >= 3) |
566 | m_log.DebugFormat( | 564 | LogIncomingToContentTypeHandler(request); |
567 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
568 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
569 | 565 | ||
570 | buffer = HandleLLSDRequests(request, response); | 566 | buffer = HandleLLSDRequests(request, response); |
571 | } | 567 | } |
@@ -573,18 +569,14 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
573 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) | 569 | else if (DoWeHaveAHTTPHandler(request.RawUrl)) |
574 | { | 570 | { |
575 | if (DebugLevel >= 3) | 571 | if (DebugLevel >= 3) |
576 | m_log.DebugFormat( | 572 | LogIncomingToContentTypeHandler(request); |
577 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
578 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
579 | 573 | ||
580 | buffer = HandleHTTPRequest(request, response); | 574 | buffer = HandleHTTPRequest(request, response); |
581 | } | 575 | } |
582 | else | 576 | else |
583 | { | 577 | { |
584 | if (DebugLevel >= 3) | 578 | if (DebugLevel >= 3) |
585 | m_log.DebugFormat( | 579 | LogIncomingToXmlRpcHandler(request); |
586 | "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", | ||
587 | request.HttpMethod, request.Url.PathAndQuery); | ||
588 | 580 | ||
589 | // generic login request. | 581 | // generic login request. |
590 | buffer = HandleXmlRpcRequests(request, response); | 582 | buffer = HandleXmlRpcRequests(request, response); |
@@ -654,6 +646,58 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
654 | } | 646 | } |
655 | } | 647 | } |
656 | 648 | ||
649 | private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) | ||
650 | { | ||
651 | m_log.DebugFormat( | ||
652 | "[BASE HTTP SERVER]: Found stream handler for {0} {1} {2} {3}", | ||
653 | request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description); | ||
654 | |||
655 | if (DebugLevel >= 4) | ||
656 | LogIncomingInDetail(request); | ||
657 | } | ||
658 | |||
659 | private void LogIncomingToContentTypeHandler(OSHttpRequest request) | ||
660 | { | ||
661 | m_log.DebugFormat( | ||
662 | "[BASE HTTP SERVER]: Found a {0} content type handler for {1} {2}", | ||
663 | request.ContentType, request.HttpMethod, request.Url.PathAndQuery); | ||
664 | |||
665 | if (DebugLevel >= 4) | ||
666 | LogIncomingInDetail(request); | ||
667 | } | ||
668 | |||
669 | private void LogIncomingToXmlRpcHandler(OSHttpRequest request) | ||
670 | { | ||
671 | m_log.DebugFormat( | ||
672 | "[BASE HTTP SERVER]: Assuming a generic XMLRPC request for {0} {1}", | ||
673 | request.HttpMethod, request.Url.PathAndQuery); | ||
674 | |||
675 | if (DebugLevel >= 4) | ||
676 | LogIncomingInDetail(request); | ||
677 | } | ||
678 | |||
679 | private void LogIncomingInDetail(OSHttpRequest request) | ||
680 | { | ||
681 | using (StreamReader reader = new StreamReader(Util.Copy(request.InputStream), Encoding.UTF8)) | ||
682 | { | ||
683 | string output; | ||
684 | |||
685 | if (DebugLevel == 4) | ||
686 | { | ||
687 | const int sampleLength = 80; | ||
688 | char[] sampleChars = new char[sampleLength]; | ||
689 | reader.Read(sampleChars, 0, sampleLength); | ||
690 | output = string.Format("[BASE HTTP SERVER]: {0}...", sampleChars); | ||
691 | } | ||
692 | else | ||
693 | { | ||
694 | output = string.Format("[BASE HTTP SERVER]: {0}", reader.ReadToEnd()); | ||
695 | } | ||
696 | |||
697 | m_log.Debug(output); | ||
698 | } | ||
699 | } | ||
700 | |||
657 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) | 701 | private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler) |
658 | { | 702 | { |
659 | string bestMatch = null; | 703 | string bestMatch = null; |