aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs204
1 files changed, 133 insertions, 71 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index f252bd5..f4ba02f 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Framework.Servers.HttpServer
58 58
59 /// <summary> 59 /// <summary>
60 /// This is a pending websocket request before it got an sucessful upgrade response. 60 /// This is a pending websocket request before it got an sucessful upgrade response.
61 /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to 61 /// The consumer must call handler.HandshakeAndUpgrade() to signal to the handler to
62 /// start the connection and optionally provide an origin authentication method. 62 /// start the connection and optionally provide an origin authentication method.
63 /// </summary> 63 /// </summary>
64 /// <param name="servicepath"></param> 64 /// <param name="servicepath"></param>
@@ -104,7 +104,7 @@ namespace OpenSim.Framework.Servers.HttpServer
104 new Dictionary<string, PollServiceEventArgs>(); 104 new Dictionary<string, PollServiceEventArgs>();
105 105
106 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers = 106 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
107 new Dictionary<string, WebSocketRequestDelegate>(); 107 new Dictionary<string, WebSocketRequestDelegate>();
108 108
109 protected uint m_port; 109 protected uint m_port;
110 protected uint m_sslport; 110 protected uint m_sslport;
@@ -253,7 +253,7 @@ namespace OpenSim.Framework.Servers.HttpServer
253 return new List<string>(m_rpcHandlers.Keys); 253 return new List<string>(m_rpcHandlers.Keys);
254 } 254 }
255 255
256 // JsonRPC 256 // JsonRPC
257 public bool AddJsonRPCHandler(string method, JsonRPCMethod handler) 257 public bool AddJsonRPCHandler(string method, JsonRPCMethod handler)
258 { 258 {
259 lock(jsonRpcHandlers) 259 lock(jsonRpcHandlers)
@@ -399,10 +399,10 @@ namespace OpenSim.Framework.Servers.HttpServer
399 399
400 Stream requestStream = req.InputStream; 400 Stream requestStream = req.InputStream;
401 401
402 string requestBody;
402 Encoding encoding = Encoding.UTF8; 403 Encoding encoding = Encoding.UTF8;
403 StreamReader reader = new StreamReader(requestStream, encoding); 404 using(StreamReader reader = new StreamReader(requestStream, encoding))
404 405 requestBody = reader.ReadToEnd();
405 string requestBody = reader.ReadToEnd();
406 406
407 Hashtable keysvals = new Hashtable(); 407 Hashtable keysvals = new Hashtable();
408 Hashtable headervals = new Hashtable(); 408 Hashtable headervals = new Hashtable();
@@ -458,10 +458,11 @@ namespace OpenSim.Framework.Servers.HttpServer
458 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192)); 458 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHttpServerHandler(req, context, 8192));
459 return; 459 return;
460 } 460 }
461 461
462 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 462 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
463 resp.ReuseContext = true; 463 resp.ReuseContext = true;
464 HandleRequest(req, resp); 464// resp.ReuseContext = false;
465 HandleRequest(req, resp);
465 466
466 // !!!HACK ALERT!!! 467 // !!!HACK ALERT!!!
467 // There seems to be a bug in the underlying http code that makes subsequent requests 468 // There seems to be a bug in the underlying http code that makes subsequent requests
@@ -552,7 +553,7 @@ namespace OpenSim.Framework.Servers.HttpServer
552 LogIncomingToStreamHandler(request, requestHandler); 553 LogIncomingToStreamHandler(request, requestHandler);
553 554
554 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 555 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
555 556
556 if (requestHandler is IStreamedRequestHandler) 557 if (requestHandler is IStreamedRequestHandler)
557 { 558 {
558 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 559 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@@ -565,13 +566,10 @@ namespace OpenSim.Framework.Servers.HttpServer
565 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; 566 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
566 Stream requestStream = request.InputStream; 567 Stream requestStream = request.InputStream;
567 568
569 string requestBody;
568 Encoding encoding = Encoding.UTF8; 570 Encoding encoding = Encoding.UTF8;
569 StreamReader reader = new StreamReader(requestStream, encoding); 571 using(StreamReader reader = new StreamReader(requestStream, encoding))
570 572 requestBody = reader.ReadToEnd();
571 string requestBody = reader.ReadToEnd();
572
573 reader.Close();
574 //requestStream.Close();
575 573
576 Hashtable keysvals = new Hashtable(); 574 Hashtable keysvals = new Hashtable();
577 Hashtable headervals = new Hashtable(); 575 Hashtable headervals = new Hashtable();
@@ -628,16 +626,16 @@ namespace OpenSim.Framework.Servers.HttpServer
628 case "text/html": 626 case "text/html":
629 if (DebugLevel >= 3) 627 if (DebugLevel >= 3)
630 LogIncomingToContentTypeHandler(request); 628 LogIncomingToContentTypeHandler(request);
631 629
632 buffer = HandleHTTPRequest(request, response); 630 buffer = HandleHTTPRequest(request, response);
633 break; 631 break;
634 632
635 case "application/llsd+xml": 633 case "application/llsd+xml":
636 case "application/xml+llsd": 634 case "application/xml+llsd":
637 case "application/llsd+json": 635 case "application/llsd+json":
638 if (DebugLevel >= 3) 636 if (DebugLevel >= 3)
639 LogIncomingToContentTypeHandler(request); 637 LogIncomingToContentTypeHandler(request);
640 638
641 buffer = HandleLLSDRequests(request, response); 639 buffer = HandleLLSDRequests(request, response);
642 break; 640 break;
643 641
@@ -647,7 +645,7 @@ namespace OpenSim.Framework.Servers.HttpServer
647 645
648 buffer = HandleJsonRpcRequests(request, response); 646 buffer = HandleJsonRpcRequests(request, response);
649 break; 647 break;
650 648
651 case "text/xml": 649 case "text/xml":
652 case "application/xml": 650 case "application/xml":
653 case "application/json": 651 case "application/json":
@@ -664,7 +662,7 @@ namespace OpenSim.Framework.Servers.HttpServer
664 { 662 {
665 if (DebugLevel >= 3) 663 if (DebugLevel >= 3)
666 LogIncomingToContentTypeHandler(request); 664 LogIncomingToContentTypeHandler(request);
667 665
668 buffer = HandleLLSDRequests(request, response); 666 buffer = HandleLLSDRequests(request, response);
669 } 667 }
670 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl); 668 // m_log.DebugFormat("[BASE HTTP SERVER]: Checking for HTTP Handler for request {0}", request.RawUrl);
@@ -672,23 +670,24 @@ namespace OpenSim.Framework.Servers.HttpServer
672 { 670 {
673 if (DebugLevel >= 3) 671 if (DebugLevel >= 3)
674 LogIncomingToContentTypeHandler(request); 672 LogIncomingToContentTypeHandler(request);
675 673
676 buffer = HandleHTTPRequest(request, response); 674 buffer = HandleHTTPRequest(request, response);
677 } 675 }
678 else 676 else
679 { 677 {
680 if (DebugLevel >= 3) 678 if (DebugLevel >= 3)
681 LogIncomingToXmlRpcHandler(request); 679 LogIncomingToXmlRpcHandler(request);
682 680
683 // generic login request. 681 // generic login request.
684 buffer = HandleXmlRpcRequests(request, response); 682 buffer = HandleXmlRpcRequests(request, response);
685 } 683 }
686 684
687 break; 685 break;
688 } 686 }
689 } 687 }
690 688
691 request.InputStream.Close(); 689 if(request.InputStream.CanRead)
690 request.InputStream.Dispose();
692 691
693 if (buffer != null) 692 if (buffer != null)
694 { 693 {
@@ -759,7 +758,7 @@ namespace OpenSim.Framework.Servers.HttpServer
759 // Every month or so this will wrap and give bad numbers, not really a problem 758 // Every month or so this will wrap and give bad numbers, not really a problem
760 // since its just for reporting 759 // since its just for reporting
761 int tickdiff = requestEndTick - requestStartTick; 760 int tickdiff = requestEndTick - requestStartTick;
762 if (tickdiff > 3000 && requestHandler != null && requestHandler.Name != "GetTexture") 761 if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture"))
763 { 762 {
764 m_log.InfoFormat( 763 m_log.InfoFormat(
765 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms", 764 "[LOGHTTP] Slow handling of {0} {1} {2} {3} {4} from {5} took {6}ms",
@@ -970,7 +969,7 @@ namespace OpenSim.Framework.Servers.HttpServer
970// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) 969// private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler)
971// { 970// {
972// agentHandler = null; 971// agentHandler = null;
973// 972//
974// lock (m_agentHandlers) 973// lock (m_agentHandlers)
975// { 974// {
976// foreach (IHttpAgentHandler handler in m_agentHandlers.Values) 975// foreach (IHttpAgentHandler handler in m_agentHandlers.Values)
@@ -996,7 +995,7 @@ namespace OpenSim.Framework.Servers.HttpServer
996 { 995 {
997 String requestBody; 996 String requestBody;
998 997
999 Stream requestStream = request.InputStream; 998 Stream requestStream = Util.Copy(request.InputStream);
1000 Stream innerStream = null; 999 Stream innerStream = null;
1001 try 1000 try
1002 { 1001 {
@@ -1007,9 +1006,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1007 } 1006 }
1008 1007
1009 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) 1008 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
1010 {
1011 requestBody = reader.ReadToEnd(); 1009 requestBody = reader.ReadToEnd();
1012 } 1010
1013 } 1011 }
1014 finally 1012 finally
1015 { 1013 {
@@ -1024,6 +1022,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1024 string responseString = String.Empty; 1022 string responseString = String.Empty;
1025 XmlRpcRequest xmlRprcRequest = null; 1023 XmlRpcRequest xmlRprcRequest = null;
1026 1024
1025 bool gridproxy = false;
1026 if (requestBody.Contains("encoding=\"utf-8"))
1027 {
1028 int channelindx = -1;
1029 int optionsindx = requestBody.IndexOf(">options<");
1030 if(optionsindx >0)
1031 {
1032 channelindx = requestBody.IndexOf(">channel<");
1033 if (optionsindx < channelindx)
1034 gridproxy = true;
1035 }
1036 }
1037
1027 try 1038 try
1028 { 1039 {
1029 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody); 1040 xmlRprcRequest = (XmlRpcRequest) (new XmlRpcRequestDeserializer()).Deserialize(requestBody);
@@ -1081,6 +1092,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1081 } 1092 }
1082 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] 1093 xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3]
1083 1094
1095 if (gridproxy)
1096 xmlRprcRequest.Params.Add("gridproxy"); // Param[4]
1084 try 1097 try
1085 { 1098 {
1086 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); 1099 xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint);
@@ -1154,7 +1167,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1154 return buffer; 1167 return buffer;
1155 } 1168 }
1156 1169
1157 // JsonRpc (v2.0 only) 1170 // JsonRpc (v2.0 only)
1158 // Batch requests not yet supported 1171 // Batch requests not yet supported
1159 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response) 1172 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response)
1160 { 1173 {
@@ -1171,7 +1184,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1171 jsonRpcResponse.Error.Code = ErrorCode.InternalError; 1184 jsonRpcResponse.Error.Code = ErrorCode.InternalError;
1172 jsonRpcResponse.Error.Message = e.Message; 1185 jsonRpcResponse.Error.Message = e.Message;
1173 } 1186 }
1174 1187
1175 requestStream.Close(); 1188 requestStream.Close();
1176 1189
1177 if (jsonRpcRequest != null) 1190 if (jsonRpcRequest != null)
@@ -1236,7 +1249,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1236 string responseData = string.Empty; 1249 string responseData = string.Empty;
1237 1250
1238 responseData = jsonRpcResponse.Serialize(); 1251 responseData = jsonRpcResponse.Serialize();
1239 1252
1240 byte[] buffer = Encoding.UTF8.GetBytes(responseData); 1253 byte[] buffer = Encoding.UTF8.GetBytes(responseData);
1241 return buffer; 1254 return buffer;
1242 } 1255 }
@@ -1246,12 +1259,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1246 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); 1259 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
1247 Stream requestStream = request.InputStream; 1260 Stream requestStream = request.InputStream;
1248 1261
1262 string requestBody;
1249 Encoding encoding = Encoding.UTF8; 1263 Encoding encoding = Encoding.UTF8;
1250 StreamReader reader = new StreamReader(requestStream, encoding); 1264 using(StreamReader reader = new StreamReader(requestStream, encoding))
1251 1265 requestBody= reader.ReadToEnd();
1252 string requestBody = reader.ReadToEnd();
1253 reader.Close();
1254 requestStream.Close();
1255 1266
1256 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); 1267 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
1257 response.KeepAlive = true; 1268 response.KeepAlive = true;
@@ -1516,7 +1527,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1516 } 1527 }
1517 } 1528 }
1518 } 1529 }
1519 1530
1520 if (String.IsNullOrEmpty(bestMatch)) 1531 if (String.IsNullOrEmpty(bestMatch))
1521 { 1532 {
1522 llsdHandler = null; 1533 llsdHandler = null;
@@ -1575,15 +1586,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1575 byte[] buffer; 1586 byte[] buffer;
1576 1587
1577 Stream requestStream = request.InputStream; 1588 Stream requestStream = request.InputStream;
1578 1589 string requestBody;
1579 Encoding encoding = Encoding.UTF8; 1590 Encoding encoding = Encoding.UTF8;
1580 StreamReader reader = new StreamReader(requestStream, encoding); 1591 using(StreamReader reader = new StreamReader(requestStream, encoding))
1581 1592 requestBody = reader.ReadToEnd();
1582 string requestBody = reader.ReadToEnd();
1583 // avoid warning for now
1584 reader.ReadToEnd();
1585 reader.Close();
1586 requestStream.Close();
1587 1593
1588 Hashtable keysvals = new Hashtable(); 1594 Hashtable keysvals = new Hashtable();
1589 Hashtable headervals = new Hashtable(); 1595 Hashtable headervals = new Hashtable();
@@ -1732,10 +1738,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1732 1738
1733 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response) 1739 internal byte[] DoHTTPGruntWork(Hashtable responsedata, OSHttpResponse response)
1734 { 1740 {
1735 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); 1741 int responsecode;
1736 int responsecode = (int)responsedata["int_response_code"]; 1742 string responseString = String.Empty;
1737 string responseString = (string)responsedata["str_response_string"]; 1743 byte[] responseData = null;
1738 string contentType = (string)responsedata["content_type"]; 1744 string contentType;
1745
1746 if (responsedata == null)
1747 {
1748 responsecode = 500;
1749 responseString = "No response could be obtained";
1750 contentType = "text/plain";
1751 responsedata = new Hashtable();
1752 }
1753 else
1754 {
1755 try
1756 {
1757 //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response");
1758 responsecode = (int)responsedata["int_response_code"];
1759 if (responsedata["bin_response_data"] != null)
1760 responseData = (byte[])responsedata["bin_response_data"];
1761 else
1762 responseString = (string)responsedata["str_response_string"];
1763 contentType = (string)responsedata["content_type"];
1764 if (responseString == null)
1765 responseString = String.Empty;
1766 }
1767 catch
1768 {
1769 responsecode = 500;
1770 responseString = "No response could be obtained";
1771 contentType = "text/plain";
1772 responsedata = new Hashtable();
1773 }
1774 }
1739 1775
1740 if (responsedata.ContainsKey("error_status_text")) 1776 if (responsedata.ContainsKey("error_status_text"))
1741 { 1777 {
@@ -1745,16 +1781,19 @@ namespace OpenSim.Framework.Servers.HttpServer
1745 { 1781 {
1746 response.ProtocolVersion = (string)responsedata["http_protocol_version"]; 1782 response.ProtocolVersion = (string)responsedata["http_protocol_version"];
1747 } 1783 }
1748 1784/*
1749 if (responsedata.ContainsKey("keepalive")) 1785 if (responsedata.ContainsKey("keepalive"))
1750 { 1786 {
1751 bool keepalive = (bool)responsedata["keepalive"]; 1787 bool keepalive = (bool)responsedata["keepalive"];
1752 response.KeepAlive = keepalive; 1788 response.KeepAlive = keepalive;
1753
1754 } 1789 }
1755 1790
1756 if (responsedata.ContainsKey("reusecontext")) 1791 if (responsedata.ContainsKey("reusecontext"))
1757 response.ReuseContext = (bool) responsedata["reusecontext"]; 1792 response.ReuseContext = (bool) responsedata["reusecontext"];
1793*/
1794 // disable this things
1795 response.KeepAlive = false;
1796 response.ReuseContext = false;
1758 1797
1759 // Cross-Origin Resource Sharing with simple requests 1798 // Cross-Origin Resource Sharing with simple requests
1760 if (responsedata.ContainsKey("access_control_allow_origin")) 1799 if (responsedata.ContainsKey("access_control_allow_origin"))
@@ -1768,8 +1807,11 @@ namespace OpenSim.Framework.Servers.HttpServer
1768 contentType = "text/html"; 1807 contentType = "text/html";
1769 } 1808 }
1770 1809
1810
1811
1771 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that 1812 // The client ignores anything but 200 here for web login, so ensure that this is 200 for that
1772 1813
1814
1773 response.StatusCode = responsecode; 1815 response.StatusCode = responsecode;
1774 1816
1775 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently) 1817 if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
@@ -1780,25 +1822,40 @@ namespace OpenSim.Framework.Servers.HttpServer
1780 1822
1781 response.AddHeader("Content-Type", contentType); 1823 response.AddHeader("Content-Type", contentType);
1782 1824
1825 if (responsedata.ContainsKey("headers"))
1826 {
1827 Hashtable headerdata = (Hashtable)responsedata["headers"];
1828
1829 foreach (string header in headerdata.Keys)
1830 response.AddHeader(header, headerdata[header].ToString());
1831 }
1832
1783 byte[] buffer; 1833 byte[] buffer;
1784 1834
1785 if (!(contentType.Contains("image") 1835 if (responseData != null)
1786 || contentType.Contains("x-shockwave-flash")
1787 || contentType.Contains("application/x-oar")
1788 || contentType.Contains("application/vnd.ll.mesh")))
1789 { 1836 {
1790 // Text 1837 buffer = responseData;
1791 buffer = Encoding.UTF8.GetBytes(responseString);
1792 } 1838 }
1793 else 1839 else
1794 { 1840 {
1795 // Binary! 1841 if (!(contentType.Contains("image")
1796 buffer = Convert.FromBase64String(responseString); 1842 || contentType.Contains("x-shockwave-flash")
1797 } 1843 || contentType.Contains("application/x-oar")
1844 || contentType.Contains("application/vnd.ll.mesh")))
1845 {
1846 // Text
1847 buffer = Encoding.UTF8.GetBytes(responseString);
1848 }
1849 else
1850 {
1851 // Binary!
1852 buffer = Convert.FromBase64String(responseString);
1853 }
1798 1854
1799 response.SendChunked = false; 1855 response.SendChunked = false;
1800 response.ContentLength64 = buffer.Length; 1856 response.ContentLength64 = buffer.Length;
1801 response.ContentEncoding = Encoding.UTF8; 1857 response.ContentEncoding = Encoding.UTF8;
1858 }
1802 1859
1803 return buffer; 1860 return buffer;
1804 } 1861 }
@@ -1831,8 +1888,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1831 response.SendChunked = false; 1888 response.SendChunked = false;
1832 response.ContentLength64 = buffer.Length; 1889 response.ContentLength64 = buffer.Length;
1833 response.ContentEncoding = Encoding.UTF8; 1890 response.ContentEncoding = Encoding.UTF8;
1834 1891
1835 1892
1836 return buffer; 1893 return buffer;
1837 } 1894 }
1838 1895
@@ -1886,7 +1943,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1886 m_httpListener2.Start(64); 1943 m_httpListener2.Start(64);
1887 1944
1888 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events 1945 // Long Poll Service Manager with 3 worker threads a 25 second timeout for no events
1889 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 3, 25000); 1946
1947 PollServiceRequestManager = new PollServiceRequestManager(this, performPollResponsesAsync, 2, 25000);
1890 PollServiceRequestManager.Start(); 1948 PollServiceRequestManager.Start();
1891 1949
1892 HTTPDRunning = true; 1950 HTTPDRunning = true;
@@ -1908,7 +1966,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1908 throw e; 1966 throw e;
1909 } 1967 }
1910 1968
1911 m_requestsProcessedStat 1969 m_requestsProcessedStat
1912 = new Stat( 1970 = new Stat(
1913 "HTTPRequestsServed", 1971 "HTTPRequestsServed",
1914 "Number of inbound HTTP requests processed", 1972 "Number of inbound HTTP requests processed",
@@ -1920,7 +1978,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1920 MeasuresOfInterest.AverageChangeOverTime, 1978 MeasuresOfInterest.AverageChangeOverTime,
1921 stat => stat.Value = RequestNumber, 1979 stat => stat.Value = RequestNumber,
1922 StatVerbosity.Debug); 1980 StatVerbosity.Debug);
1923 1981
1924 StatsManager.RegisterStat(m_requestsProcessedStat); 1982 StatsManager.RegisterStat(m_requestsProcessedStat);
1925 } 1983 }
1926 1984
@@ -1937,7 +1995,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1937 1995
1938 public void httpServerException(object source, Exception exception) 1996 public void httpServerException(object source, Exception exception)
1939 { 1997 {
1940 m_log.Error(String.Format("[BASE HTTP SERVER]: {0} had an exception: {1} ", source.ToString(), exception.Message), exception); 1998 if (source.ToString() == "HttpServer.HttpListener" && exception.ToString().StartsWith("Mono.Security.Protocol.Tls.TlsException"))
1999 return;
2000 m_log.ErrorFormat("[BASE HTTP SERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1941 /* 2001 /*
1942 if (HTTPDRunning)// && NotSocketErrors > 5) 2002 if (HTTPDRunning)// && NotSocketErrors > 5)
1943 { 2003 {
@@ -1957,7 +2017,8 @@ namespace OpenSim.Framework.Servers.HttpServer
1957 2017
1958 try 2018 try
1959 { 2019 {
1960 PollServiceRequestManager.Stop(); 2020 if(PollServiceRequestManager != null)
2021 PollServiceRequestManager.Stop();
1961 2022
1962 m_httpListener2.ExceptionThrown -= httpServerException; 2023 m_httpListener2.ExceptionThrown -= httpServerException;
1963 //m_httpListener2.DisconnectHandler = null; 2024 //m_httpListener2.DisconnectHandler = null;
@@ -1984,6 +2045,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1984 2045
1985 public void RemoveHTTPHandler(string httpMethod, string path) 2046 public void RemoveHTTPHandler(string httpMethod, string path)
1986 { 2047 {
2048 if (path == null) return; // Caps module isn't loaded, tries to remove handler where path = null
1987 lock (m_HTTPHandlers) 2049 lock (m_HTTPHandlers)
1988 { 2050 {
1989 if (httpMethod != null && httpMethod.Length == 0) 2051 if (httpMethod != null && httpMethod.Length == 0)