aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs205
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs22
2 files changed, 125 insertions, 102 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 4e04dd8..8c29ad4 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -62,6 +62,15 @@ namespace OpenSim.Framework.Servers.HttpServer
62 /// </value> 62 /// </value>
63 public int DebugLevel { get; set; } 63 public int DebugLevel { get; set; }
64 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
65 private volatile int NotSocketErrors = 0; 74 private volatile int NotSocketErrors = 0;
66 public volatile bool HTTPDRunning = false; 75 public volatile bool HTTPDRunning = false;
67 76
@@ -73,7 +82,7 @@ namespace OpenSim.Framework.Servers.HttpServer
73 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); 82 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
74 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 83 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
75 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); 84 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
76 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); 85// protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
77 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = 86 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
78 new Dictionary<string, PollServiceEventArgs>(); 87 new Dictionary<string, PollServiceEventArgs>();
79 88
@@ -251,29 +260,29 @@ namespace OpenSim.Framework.Servers.HttpServer
251 return new List<string>(m_pollHandlers.Keys); 260 return new List<string>(m_pollHandlers.Keys);
252 } 261 }
253 262
254 // Note that the agent string is provided simply to differentiate 263// // Note that the agent string is provided simply to differentiate
255 // 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
256 // value. 265// // value.
257 public bool AddAgentHandler(string agent, IHttpAgentHandler handler) 266// public bool AddAgentHandler(string agent, IHttpAgentHandler handler)
258 { 267// {
259 lock (m_agentHandlers) 268// lock (m_agentHandlers)
260 { 269// {
261 if (!m_agentHandlers.ContainsKey(agent)) 270// if (!m_agentHandlers.ContainsKey(agent))
262 { 271// {
263 m_agentHandlers.Add(agent, handler); 272// m_agentHandlers.Add(agent, handler);
264 return true; 273// return true;
265 } 274// }
266 } 275// }
267 276//
268 //must already have a handler for that path so return false 277// //must already have a handler for that path so return false
269 return false; 278// return false;
270 } 279// }
271 280//
272 public List<string> GetAgentHandlerKeys() 281// public List<string> GetAgentHandlerKeys()
273 { 282// {
274 lock (m_agentHandlers) 283// lock (m_agentHandlers)
275 return new List<string>(m_agentHandlers.Keys); 284// return new List<string>(m_agentHandlers.Keys);
276 } 285// }
277 286
278 public bool AddLLSDHandler(string path, LLSDMethod handler) 287 public bool AddLLSDHandler(string path, LLSDMethod handler)
279 { 288 {
@@ -302,6 +311,8 @@ namespace OpenSim.Framework.Servers.HttpServer
302 311
303 private void OnRequest(object source, RequestEventArgs args) 312 private void OnRequest(object source, RequestEventArgs args)
304 { 313 {
314 RequestNumber++;
315
305 try 316 try
306 { 317 {
307 IHttpClientContext context = (IHttpClientContext)source; 318 IHttpClientContext context = (IHttpClientContext)source;
@@ -411,7 +422,6 @@ namespace OpenSim.Framework.Servers.HttpServer
411 string requestMethod = request.HttpMethod; 422 string requestMethod = request.HttpMethod;
412 string uriString = request.RawUrl; 423 string uriString = request.RawUrl;
413 424
414// string reqnum = "unknown";
415 int requestStartTick = Environment.TickCount; 425 int requestStartTick = Environment.TickCount;
416 426
417 // Will be adjusted later on. 427 // Will be adjusted later on.
@@ -428,22 +438,22 @@ namespace OpenSim.Framework.Servers.HttpServer
428 438
429 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); 439 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true);
430 440
431 // This is the REST agent interface. We require an agent to properly identify 441// // This is the REST agent interface. We require an agent to properly identify
432 // itself. If the REST handler recognizes the prefix it will attempt to 442// // itself. If the REST handler recognizes the prefix it will attempt to
433 // satisfy the request. If it is not recognizable, and no damage has occurred 443// // satisfy the request. If it is not recognizable, and no damage has occurred
434 // the request can be passed through to the other handlers. This is a low 444// // the request can be passed through to the other handlers. This is a low
435 // probability event; if a request is matched it is normally expected to be 445// // probability event; if a request is matched it is normally expected to be
436 // handled 446// // handled
437 IHttpAgentHandler agentHandler; 447// IHttpAgentHandler agentHandler;
438 448//
439 if (TryGetAgentHandler(request, response, out agentHandler)) 449// if (TryGetAgentHandler(request, response, out agentHandler))
440 { 450// {
441 if (HandleAgentRequest(agentHandler, request, response)) 451// if (HandleAgentRequest(agentHandler, request, response))
442 { 452// {
443 requestEndTick = Environment.TickCount; 453// requestEndTick = Environment.TickCount;
444 return; 454// return;
445 } 455// }
446 } 456// }
447 457
448 //response.KeepAlive = true; 458 //response.KeepAlive = true;
449 response.SendChunked = false; 459 response.SendChunked = false;
@@ -535,8 +545,8 @@ namespace OpenSim.Framework.Servers.HttpServer
535 545
536 if (DebugLevel >= 3) 546 if (DebugLevel >= 3)
537 m_log.DebugFormat( 547 m_log.DebugFormat(
538 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", 548 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
539 request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); 549 RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
540 550
541 buffer = HandleHTTPRequest(request, response); 551 buffer = HandleHTTPRequest(request, response);
542 break; 552 break;
@@ -547,8 +557,8 @@ namespace OpenSim.Framework.Servers.HttpServer
547 557
548 if (DebugLevel >= 3) 558 if (DebugLevel >= 3)
549 m_log.DebugFormat( 559 m_log.DebugFormat(
550 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", 560 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
551 request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); 561 RequestNumber, Port, request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint);
552 562
553 buffer = HandleLLSDRequests(request, response); 563 buffer = HandleLLSDRequests(request, response);
554 break; 564 break;
@@ -641,7 +651,8 @@ namespace OpenSim.Framework.Servers.HttpServer
641 if (tickdiff > 3000) 651 if (tickdiff > 3000)
642 { 652 {
643 m_log.InfoFormat( 653 m_log.InfoFormat(
644 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", 654 "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
655 RequestNumber,
645 requestMethod, 656 requestMethod,
646 uriString, 657 uriString,
647 requestHandler != null ? requestHandler.Name : "", 658 requestHandler != null ? requestHandler.Name : "",
@@ -652,12 +663,9 @@ namespace OpenSim.Framework.Servers.HttpServer
652 else if (DebugLevel >= 4) 663 else if (DebugLevel >= 4)
653 { 664 {
654 m_log.DebugFormat( 665 m_log.DebugFormat(
655 "[BASE HTTP SERVER]: HTTP IN {0} {1} {2} {3} from {4} took {5}ms", 666 "[BASE HTTP SERVER]: HTTP IN {0} :{1} took {2}ms",
656 requestMethod, 667 RequestNumber,
657 uriString, 668 Port,
658 requestHandler != null ? requestHandler.Name : "",
659 requestHandler != null ? requestHandler.Description : "",
660 request.RemoteIPEndPoint,
661 tickdiff); 669 tickdiff);
662 } 670 }
663 } 671 }
@@ -666,8 +674,14 @@ namespace OpenSim.Framework.Servers.HttpServer
666 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler) 674 private void LogIncomingToStreamHandler(OSHttpRequest request, IRequestHandler requestHandler)
667 { 675 {
668 m_log.DebugFormat( 676 m_log.DebugFormat(
669 "[BASE HTTP SERVER]: HTTP IN stream handler {0} {1} {2} {3} from {4}", 677 "[BASE HTTP SERVER]: HTTP IN {0} :{1} stream handler {2} {3} {4} {5} from {6}",
670 request.HttpMethod, request.Url.PathAndQuery, requestHandler.Name, requestHandler.Description, request.RemoteIPEndPoint); 678 RequestNumber,
679 Port,
680 request.HttpMethod,
681 request.Url.PathAndQuery,
682 requestHandler.Name,
683 requestHandler.Description,
684 request.RemoteIPEndPoint);
671 685
672 if (DebugLevel >= 5) 686 if (DebugLevel >= 5)
673 LogIncomingInDetail(request); 687 LogIncomingInDetail(request);
@@ -676,8 +690,13 @@ namespace OpenSim.Framework.Servers.HttpServer
676 private void LogIncomingToContentTypeHandler(OSHttpRequest request) 690 private void LogIncomingToContentTypeHandler(OSHttpRequest request)
677 { 691 {
678 m_log.DebugFormat( 692 m_log.DebugFormat(
679 "[BASE HTTP SERVER]: HTTP IN {0} content type handler {1} {2} from {3}", 693 "[BASE HTTP SERVER]: HTTP IN {0} :{1} {2} content type handler {3} {4} from {5}",
680 request.ContentType, request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); 694 RequestNumber,
695 Port,
696 request.ContentType,
697 request.HttpMethod,
698 request.Url.PathAndQuery,
699 request.RemoteIPEndPoint);
681 700
682 if (DebugLevel >= 5) 701 if (DebugLevel >= 5)
683 LogIncomingInDetail(request); 702 LogIncomingInDetail(request);
@@ -686,8 +705,12 @@ namespace OpenSim.Framework.Servers.HttpServer
686 private void LogIncomingToXmlRpcHandler(OSHttpRequest request) 705 private void LogIncomingToXmlRpcHandler(OSHttpRequest request)
687 { 706 {
688 m_log.DebugFormat( 707 m_log.DebugFormat(
689 "[BASE HTTP SERVER]: HTTP IN assumed generic XMLRPC request {0} {1} from {2}", 708 "[BASE HTTP SERVER]: HTTP IN {0} :{1} assumed generic XMLRPC request {2} {3} from {4}",
690 request.HttpMethod, request.Url.PathAndQuery, request.RemoteIPEndPoint); 709 RequestNumber,
710 Port,
711 request.HttpMethod,
712 request.Url.PathAndQuery,
713 request.RemoteIPEndPoint);
691 714
692 if (DebugLevel >= 5) 715 if (DebugLevel >= 5)
693 LogIncomingInDetail(request); 716 LogIncomingInDetail(request);
@@ -807,24 +830,24 @@ namespace OpenSim.Framework.Servers.HttpServer
807 } 830 }
808 } 831 }
809 832
810 private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) 833// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
811 { 834// {
812 agentHandler = null; 835// agentHandler = null;
813 836//
814 lock (m_agentHandlers) 837// lock (m_agentHandlers)
815 { 838// {
816 foreach (IHttpAgentHandler handler in m_agentHandlers.Values) 839// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
817 { 840// {
818 if (handler.Match(request, response)) 841// if (handler.Match(request, response))
819 { 842// {
820 agentHandler = handler; 843// agentHandler = handler;
821 return true; 844// return true;
822 } 845// }
823 } 846// }
824 } 847// }
825 848//
826 return false; 849// return false;
827 } 850// }
828 851
829 /// <summary> 852 /// <summary>
830 /// Try all the registered xmlrpc handlers when an xmlrpc request is received. 853 /// Try all the registered xmlrpc handlers when an xmlrpc request is received.
@@ -1749,21 +1772,21 @@ namespace OpenSim.Framework.Servers.HttpServer
1749 m_pollHandlers.Remove(path); 1772 m_pollHandlers.Remove(path);
1750 } 1773 }
1751 1774
1752 public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) 1775// public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler)
1753 { 1776// {
1754 lock (m_agentHandlers) 1777// lock (m_agentHandlers)
1755 { 1778// {
1756 IHttpAgentHandler foundHandler; 1779// IHttpAgentHandler foundHandler;
1757 1780//
1758 if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) 1781// if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler)
1759 { 1782// {
1760 m_agentHandlers.Remove(agent); 1783// m_agentHandlers.Remove(agent);
1761 return true; 1784// return true;
1762 } 1785// }
1763 } 1786// }
1764 1787//
1765 return false; 1788// return false;
1766 } 1789// }
1767 1790
1768 public void RemoveXmlRPCHandler(string method) 1791 public void RemoveXmlRPCHandler(string method)
1769 { 1792 {
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